how to continue loop in python code example
Example 1: continue statement python
import numpy as np
values=np.arange(0,10)
for value in values:
if value==3:
continue
elif value==8:
print('Eight value')
elif value==9:
break
Example 2: python while continue
while True:
print('Who are you?')
name = input()
if name != 'Joe':
continue
print('Hello, Joe. What is the password? (It is a fish.)')
password = input()
if password == 'swordfish':
break
print('Access granted.')
Example 3: python for continue
>>> for num in range(2, 10):
... if num % 2 == 0:
... print("Found an even number", num)
... continue
... print("Found a number", num)
Found an even number 2
Found a number 3
Found an even number 4
Found a number 5
Found an even number 6
Found a number 7
Found an even number 8
Found a number 9