Control Flow and Looping (Invalid Syntax)


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/0/3?curriculum_id=4f89dab3d788890003000096#

Your code threw the following error: invalid syntax (python, line 3)

I expecting all numbers to be divisible by 2.


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


#2

when doing division you would do:

5 / 2 == 1

when using the modulo operator, its not different, simply use %, not ==%


#3

Alright, I typed in this code:

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

It still didn't work.


#4

a is the list, you should check if the elements inside the list are even


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.