Im trying to teach myself a little bit of python and have become stuck/frustrated. Im on Python.org and so far have had no luck.
First, the objective is not too clear "Loop through and print out all even numbers from the numbers list in the same order they are received, but only up to the number "412" (not including it) Stop there and ignore all numbers past 412 in the sequence. (Note there will be numbers over 412.)"
Ive tried just filtering out the even numbers and i get back a list that is different from the expected outcome. I have double didget numbers where in the expected outcome is 3 didget numbers.
for theanswer in numbers:
if theanswer % 2 == 0:
print theanswer
Ive been working on this since last night and have changed the code about 40 times. Its probably something simple that i am missing, but i just cant figure this out.
My current code is
for theanswer in numbers:
if theanswer ==412:
continue
if theanswer % 2 == 0:
print theanswer
That filters out the 412 and prints only even numbers. But the expected outcome is still way off. Not in the same order and i still have double didget numbers also. I know i can add another if statement to remove the double didget numbers, but i feel like im going in the wrong direction here!?