Break & Continue In Python
Code Example
# Break
n = input("Enter Break Number [1-10] : ")
print(type(n))
n = int(n)
print(type(n))
for i in range(1, 11, 1):
print(i)
if i == n:
break
else:
pass
Output:
Enter Break Number [1-10] : 7 <class 'str'> <class 'int'> 1 2 3 4 5 6 7
# Continue
n = input("Enter Skip Number [1-10] : ")
print(type(n))
n = int(n)
print(type(n))
for i in range(1, 11, 1):
if i == n:
continue
print(i)
Output:
Enter Skip Number [1-10] : 4 <class 'str'> <class 'int'> 1 2 3 5 6 7 8 9 10
Enjoy Edge-cutting Technology 😉
Comments
Post a Comment