end while loop in python code example

Example 1: python exit loop iteration

alphabet = ['a' , 'b' , 'c' , 'd' ]
for letter in alphabet:
  if letter == 'b' :
    continue
    #continues to next iteration
  print( letter )
for letter in alphabet:
  if letter == 'b' :
    break
    #terminates current loop
  print( letter )
for letter in alphabet:
  if letter == 'b' :
    pass
    #does nothing
  print( letter )

Example 2: while not command in python

condition = 3

while not (condition == 0) :
   print(condition)
   condition = condition - 1

Example 3: python exit while loop

while (True):
	# ...
    break