SimpleTuts.com

Python While Loop

A while loop in Python repeatedly executes a block of statements as long as a specified condition remains true.


i = 1
while i < 6:
  print(i)
  i += 1
                
Python Online Compiler

Using break and continue


i = 0
limit = int(input("Enter the limit : "))
while i < limit:
  i += 3
  if i == 12:
    continue
  if i == 24:
    break
  print(i)
                
Python Online Compiler