Is this an infinity loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is this an infinity loop?

I was trying to create a python code of an infinity loop with the for loop. Is this an infinity loop? It simply says no output here. https://code.sololearn.com/cptLLQBqzlDi/?ref=app

19th Sep 2022, 4:37 PM
Gamer To The Core- Born Gamer
Gamer To The Core- Born Gamer - avatar
5 Answers
+ 3
No, this is not an endless loop. Since you set the cycle step to negative, it does not fall in the range from 1 to 10, so the cycle will not be performed.
19th Sep 2022, 4:58 PM
Solo
Solo - avatar
+ 2
Hi! Your program is not worked.
19th Sep 2022, 4:50 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
to make an infinite loop with "while" is done like this: while True: //Your code
19th Sep 2022, 10:02 PM
NinjaGamer
NinjaGamer - avatar
0
Solo okay! So in that case code is not executed even once? Like for value 1 in this case. Also, could you show me how to write an infinity loop with the for loop in python? Thanks!
19th Sep 2022, 7:57 PM
Gamer To The Core- Born Gamer
Gamer To The Core- Born Gamer - avatar
0
Absolutely. Tell me, why do you need an infinite loop and why do you want to do it with the help of "for", because with the help of "while" it is much easier?
19th Sep 2022, 9:13 PM
Solo
Solo - avatar