While loops | Sololearn: Learn to code for FREE!

+2

While loops

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 Bucci

2 Answers

New Answer

+3

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