I’m writing a function that takes an array of boolean values (specifically 1’s and 0’s) and changes each number into its base10 equivalent integer and then adds them together. The problem that I’m having is that instead of checking whether each particular element is a one or a zero and then inserting the base10 number in its place, the function is making each element a 1 and THEN performs the integer switch and the sum. So my return command at the end always results in a value of 15.

```
arr = ([8, 4, 2, 1])
for elem in arr:
if arr[0] == 1:
arr[0] = 8
elif arr[0] == 0:
arr[0] = 0
if arr[1] == 1:
arr[1] = 4
elif arr[1] == 0:
arr[1] = 0
if arr[2] == 1:
arr[2] = 2
elif arr[2] == 0:
arr[2] = 0
if arr[3] == 1:
arr[3] = 1
elif arr[3] == 0:
arr[3] = 0
return sum(arr)```
I wrote this with the idea that the function would check each element and if the element is a 1 then the appropriate integer would be instantiated in its place and if the element was a 0 then the element would remain a 0, but what's happening is that each element is being changed to a 1 and then being checked by the function.
```