+ 1

Python While loops

When I try to write this code in Jupyter it does not print anything, does anyone know why? x = 0 while x<= 20 : print(x) x += 2

15th Nov 2019, 9:01 PM
Esteban Rueda
Esteban Rueda - avatar
2 ответов
+ 5
you need to make sure that your indentation is correct, it's very critical in python. x = 0 while x <= 20: print(x) x += 2 by the way it would be easier to just use a for-loop for this task: for x in range(0, 21, 2): print(x)
15th Nov 2019, 9:12 PM
Anton Böhler
Anton Böhler - avatar
+ 1
Thank you very much!
15th Nov 2019, 9:29 PM
Esteban Rueda
Esteban Rueda - avatar