3/13


#1

i'm stuck

a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

for number in a
if number == :
print number

line 4..?


#2
if number % 2 == 0:

^^


#3

i get an error on line 3 now


#4

a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
for number in a:
if number % 2 == 0:
print number

this code worked with me, try it.
^^


#5

Can anyone help me understand why:

if number % 2 == 0

validates that the number is even. 4 is in our list, 4 % 2 is equal 2, not 0. I think we saw this in a prior lesson, but don't think it was ever explained why. Thanks.


#6

Might have figured it out. ' % ' determines remainder, correct?


#7

you indeed are correct.


#8

if number % 2 == 0:
print number

it needs to be indented


#9
for number in a:
        if number % 2 == 0:
            print number