+ 5

What is the best use of infinite loop?

I was doing the python course and I found that one can create a infinite loop, but where is can be used?

9th Mar 2018, 2:36 AM
The Coder
The Coder - avatar
2 Answers
+ 11
I use infinite loops a lot. If you have nested loops and the exit condition of the outer loop is based on the value of a variable who's scope is limited to the inner loop, the outer loop can't test it so it needs to be infinite.
9th Mar 2018, 3:57 AM
John Wells
John Wells - avatar
+ 10
infinite loops are used in apps, for example the "main loop" you stop it by the app exit key, also in games you might run a program that controls the player as long as the game is running.
9th Mar 2018, 2:56 AM
ƒred
ƒred - avatar