What does "while True" mean?

1st Mar 2016, 11:47 AM
김도현 - avatar
3 Answers
+ 1
"while True:" (always remember to capitalize "True") functions just as it sounds. To understand it better think of "True" being "2 == 2" instead. For example... "while True: print('Hi')" will function the same as... "while 2 == 2: print('Hi')" "2 == 2" is a "True" statement. So "while" "2 is equal to 2" (which it always is) 'Hi' will be printed, which would be forever. Using "while True:" is mainly used to loop and repeat a code. Using "while False:" or "while 2 == 3:" will result in no output. Mess around with it :)
13th Mar 2016, 8:30 PM
+ 1
while the computer doesn't know if something is true or if something can change is what I think it is.
22nd Jun 2016, 6:58 AM
sophie - avatar
while True: is an infinite loop . it means the code inside of it will always run (forever) unless you type break inside the block or you hold Ctrl+c in windows.
25th Jun 2016, 6:16 PM
Renken Dz
Renken Dz - avatar