Write a function listEvenNumbers2() using an infinite while loop. The function t
ID: 675162 • Letter: W
Question
Write a function listEvenNumbers2() using an infinite while loop. The function takes NO input arguments. This will be a variation of problem 1, using a loop-and-a-half pattern. The function returns the list of even numbers entered by the user. An odd number ends the interactive input. Test using the following numbers when prompted: 100, 0, 4, 13 Recap: The loop-and-a-half pattern uses an infinite loop and one-way if statement inside the body of the while loop. The function will prompt for a number inside the while loop, and if statement will test whether the user entered the flag value. in python 3.4
Explanation / Answer
def listEvenNumbers2():
a = []
while():
number = input()
if number % 2 != 0 :
break;
else:
a.append(number)
return a
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.