What is while true .I know that while 1==1: writes code infinity but I don't know the use of while true why is it use what is it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is while true .I know that while 1==1: writes code infinity but I don't know the use of while true why is it use what is it

7th Jul 2017, 5:00 PM
Asad Ullah Hashmi
Asad Ullah Hashmi - avatar
7 Answers
0
Well, 1 use I use an infinite loop for is when I make trainers for games. The program would enter an infinite loop to check if a certain process is open and keep checking until it is open and automatically hook into it. Another use would probably be a program that continuously monitors a server or something or a program that takes in user input until the user enters Quit.
7th Jul 2017, 5:11 PM
Dennis
Dennis - avatar
+ 2
While it's true, do this. When it's no longer true, stop doing that.
7th Jul 2017, 5:02 PM
AgentSmith
+ 2
Think about it, every condition of the while loop is a boolean.. What really is 1 == 1? Well 1 == 1 is true. That's the same as while true, only while true doesn't need to evaluate anything. So it's an infinite loop. Look what Netkos said. "While it's true, do this". Is the while true loop true? Well... Yeah.
7th Jul 2017, 5:08 PM
Rrestoring faith
Rrestoring faith - avatar
0
plz give an example
7th Jul 2017, 5:03 PM
Asad Ullah Hashmi
Asad Ullah Hashmi - avatar
0
I can't get while true plz give an explained example of while true with what is it and use
7th Jul 2017, 5:04 PM
Asad Ullah Hashmi
Asad Ullah Hashmi - avatar
0
1==1 ia true, because 1 is equal to 1, but you can use the keyword true (or false). Also you can write 'while 1', 1 means true and 0 means false
7th Jul 2017, 5:19 PM
Andrés04_ve
Andrés04_ve - avatar
7th Jul 2017, 5:24 PM
‎ ‏‏‎Anonymous Guy