Why we use infinite loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we use infinite loop?

10th Sep 2020, 11:44 PM
Goranov Andrian🇧🇬
Goranov Andrian🇧🇬 - avatar
2 Answers
+ 2
Wait, who said we? Well, maybe not a true infinite loop, there should always be a condition to stop the loop. There are very little reason I can think of when someone could "use" an infinite loop, most common one is to setup a prank XD
10th Sep 2020, 11:52 PM
Ipang
+ 2
There are lots of scenarios, one of many can be found in video games, here is a simple example... while player_health >= 1: play_game() else: game_over()
10th Sep 2020, 11:52 PM
Steven M
Steven M - avatar