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 😉

Quiz Level 1

Quiz Level 2


Request Me




Comments

Popular posts from this blog

How To Create .ENV File in Python

Create a Large file for Test Data Processing using Python

How to solve the Liner Equation using Python