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+=1or 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
Was this helpful?