A Day at the Supermarket 3


Good Afternoon Ladies and Gents I have a problem in the code:

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
    elif number % 2 != 0:

I get this error message:Oops, try again. Your code should have printed 2, but did not!


why do you have an elif? You just want to print out even numbers, your if statement is doing this


Yes i have an elif that is the whole code


that was not the question i asked, i asked why do you have it? Your if statement will print out all the even numbers as the exercise desires of you, so what do you still need an elif for?


Sorry are you asking why I have it or are you asking what I should use it for?


@stetim94 meant that you don't need elif block for this exercise


Oh ok I didn't understand the context he was using thank you both, Have a nice day!


@coreninja17109 gets it, your if block already does all the work required for the exercise, you don't need your elif, i hoped by asking this question you would take time to think the purpose your elif served, and then come to the conclusion you don't need it