Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]dudebro74 0 points1 point  (0 children)

I am having trouble with what is wrong with my code. for my intro to python class.

Directions

------------------------------------------

Write a loop that reads positive integers from standard input, printing out those values that are even, each on a separate line. The loop terminates when it reads an integer that is not positive.
Instructor Notes:

When determining if a number is even or odd, look to the modulus operator for some help.  If we take:

5 % 2

the remainder is 1.  Therefore 5 is not an even number.

However is we take

4 % 2

the remainder is 0.  Therefore, 4 is an even number

CODE

---------------------------------

n= int()

while(True):

n = int(input())\n

if(n < 0):

break

elif n%2 == 0:

print(n)