Jdbaba - 8 months ago 79

Python Question

I have this code:

`num = range(1,33)`

num[0]=1

num[1]=2

for i in range(2,32):

num[i]=num[i-1]+num[i-2]

total=0

for i in range(0,32):

print num[i]

if num[i]%2==0:

total=total+num[i]

else:

num[i]=num[i+1]

I want to find the sum of the even numbers in the

`num`

Answer

Indentation is very important in python

```
if num[i]%2==0:
total=total+num[i]
else:
num[i]=num[i+1]
```

should be

```
if num[i]%2==0:
total=total+num[i]
else:
num[i]=num[i+1]
```

Also, use consistent indentation e.g 4 spaces every where you have to introduce indentation.