Hello, I'm stuck at this problem. Can somebody help? You are given a program that outputs all the numbers from 0 to 10. Change the code to make it output only the even numbers. We should use while... x = 0 while print(x) x += 1 That's what I wrote but it doesn't work x = 0 while x % 2 == 0 : print(x) x += 1
4/17/2021 7:34:03 AM
Simone Bucci2 Answers
New Answerx = 0; while x <= 10: x+= 1; #Even numbers if x % 2 == 0: print(x) I think you forget to use if and else ,to perform a conditional task.
If you use while x % 2 == 0, the loop will end when the value of x is 1. https://code.sololearn.com/cZx1YMs86Hbc/?ref=app
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message