What is the purpose of making an infinite While loop? someone could give me an exemple of application? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the purpose of making an infinite While loop? someone could give me an exemple of application?

9th Feb 2016, 11:19 PM
Paula Romero
Paula Romero - avatar
2 Answers
+ 2
If you wanted something to constantly be checked in the background you could set up a value like x = 5 and then while x = 5 do whatever check you want, get it to pause for 30 seconds and then it would execute again. You could monitor wifi signal or check hard drive storage or something like that. It wouldn't be a good or efficient usage of a while loop, but it would be an application.
4th Apr 2016, 9:34 PM
Daniel O'Sullivan
Daniel O'Sullivan - avatar
+ 1
Just a comment about Daniel's answer: a shorthand and more effective way to create an infinite loop is "while True"
2nd Mar 2017, 2:29 PM
DefaltSimon
DefaltSimon - avatar