что-то пошло не так? something went wrong? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

что-то пошло не так? something went wrong?

i=2 while i<=2: print(i) i-=1

22nd Jan 2021, 4:09 AM
Gafurov Ruslan🇷🇺🤩
Gafurov Ruslan🇷🇺🤩 - avatar
1 Answer
+ 7
What were you expecting? You've set i to 2. Then you're running a while loop till i is smaller than or equal to 2, and subtracting 1 from `i` each time. So the value of `i` will keep decreasing and will always be <= 2. So it is an infinite loop that prints infinitey from 2 subtracting 1 each time
22nd Jan 2021, 4:28 AM
XXX
XXX - avatar