Like for loops, while loops are a way of going through items in a list. The difference is that while loops will continue to execute as long as a certain condition is true. To get out of the loop, use the break command, or type control-c
or quit()
in the interpreter. Otherwise, the loop will keep going.
while True:
print("Oh no! I'm stuck...")
- Check out this demonstration of while loops on w3schools.