0
what is this while true statement in python? Can someone explain??
while true Condition
2 Answers
+ 1
It execute the loop infinitely times then for exit you have to have some condition inside it for break... At example:
x= 1
while True:
if x==10:
#this break the loop saving you from infinite loop
break
# This also is important else break will not never reached
x+= 1
+ 1
while (condition):
....
executes the indented blok of code as long as the return of the condition is True.
examples:
while (x <= 3):
returns True for x <=3 and False for x >3
while (1 < 7):
always returns True
while (True):
is the same as the previous example as the condition = True