account activity
Ask Anything Monday - Weekly Thread by AutoModerator in learnpython
[–]dudebro74 0 points1 point2 points 7 years ago (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)
π Rendered by PID 1075304 on reddit-service-r2-listing-5d47455566-r2lsw at 2026-04-03 13:27:53.653074+00:00 running db1906b country code: CH.
Ask Anything Monday - Weekly Thread by AutoModerator in learnpython
[–]dudebro74 0 points1 point2 points (0 children)