Python While Loop
Syntax
The while loop in Python is used to execute a block of code repeatedly as long as the specified condition evaluates to True.
# Generic version of a while loopwhile condition: # Code to execute while the condition is True passExample
# Concrete example of a while loopcounter = 1
while counter <= 5: print(counter) counter += 1
# Output:# 1# 2# 3# 4# 5