2 loop questions stuck on | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

2 loop questions stuck on

Practicing loop questions and these first 2 are giving me a hassle. 1. 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. 2.Create a list of the odd numbers between 1 and n (include 1 as well as n -- if it's odd-- in the list). Associate the list with the variable odds. for this one I had n = 7 odds = (1, 3, 5, n) I know its wrong

4th Nov 2019, 1:40 AM
Brandon Carpenter
1 Answer
+ 2
1.solution. data=[1,2,-4,6,-2-8,4,8] for i in data: if(i<0): break; else: if(i%2==0): print(i) 2 is also same as just think.
4th Nov 2019, 2:21 AM
Maninder $ingh
Maninder $ingh - avatar