how do you stop a while loop in python code example
Example 1: while loop python
while (condition):
doThis();
Example 2: infinite while python
#infinite While on Python
while True:
print('Hello World!')
Example 3: 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 4: how to do a while loop python
while True: #True can be replaced with a different condition
#result