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. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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.

x = 0 while x<=10: if x%2==0: print(x) x+=1. In solution it is showing same code but not showing as right code

3rd Mar 2022, 9:48 AM
P Bharath
2 Answers
+ 5
Assignment operator should be the same block as if to run the loop. if(): print() x +=1
3rd Mar 2022, 9:51 AM
Simba
Simba - avatar
+ 1
Thank you so much dude
3rd Mar 2022, 9:52 AM
P Bharath