For the complete documentation index, see llms.txt. This page is also available as Markdown.

while loop

while loop iterates when condition is True until condition is False or when immediate break statement inside the loop body is run.

a=0
while a<5:
    print(a)
    a+=1

or calculate Fibonacci series

a, b = 0, 1
fib=[]
while True:
#    print(a)
    if len(fib)>=10:
        break
    else:
        fib.append(a)
    a, b = b, a+b 
    print(fib[-1], end=" ")

Last updated