Where we use 'while true' condition | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Where we use 'while true' condition

While loop

21st Jan 2019, 4:23 PM
Roshan Pradhan
Roshan Pradhan - avatar
3 Answers
+ 3
Sometimes you don't want or can't define what will be the ending condition of the loop. So by using true, the loop goes on and on. The point is to create an abort condition in the code block instead, using break. For example (in Python since you seem to be studying that): list_ = [] while True: x = input() if not x: break list_.append(x)
21st Jan 2019, 4:56 PM
HonFu
HonFu - avatar
+ 1
Thanks
12th Feb 2019, 6:16 AM
Roshan Pradhan
Roshan Pradhan - avatar
0
For making an infinite loop
21st Jan 2019, 4:33 PM
Etabeta1🇮🇹
Etabeta1🇮🇹 - avatar