Control Flow and looping Looping


#1

I keep getting an error saying: You can only use one print statement for this exercise!

I don't understand why, here's my code:

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

# Loop through each value in list a
for i in a:
    # If the value is 0, skip over it
    if a[i] != 0:
        b = a[i] % 2
        # If the value is even, print it to the console
        if b == 0:
            print a[i]

#2

What if you try this slightly altered version? ---

a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
# Loop through each value in list a
for i in a:
    # If the value is 0, skip over it
    if i == 0:
        continue # ('continue' lets us skip 0 and carry on with the next value in the list)
        # If the value is even, print it to the console
    elif i%2 == 0:
        print i

This way you don't have to assign a 2nd variable for i. Good luck!