How to use while True in Python
while True in Python executes a loop infinitely until a
break statement is run when a condition is met.
To demonstrate this, let's create an infinite loop using
while True and increment the value of
count on each iteration. When the
count reaches 10 we will break the loop.
count = 0 while True: if count == 10: break count = count + 1 print(count)
1 2 3 4 5 6 7 8 9 10