Print the numbers by breaking a loop in Python.

In this program, we will print the numbers by breaking a loop in Python.

Steps to solve the program
  1. Use for loop to iterate over numbers from 1-10.
  2. If a number is not equal to 6 print the number.
  3. If a number is equal to 6 break the loop.
				
					
for i in range(1,11):
    if i != 6:
        print(i)
    if i == 6:
        break
				
			

Output :

				
					1
2
3
4
5
				
			

print 1-10 natural numbers but it should stop when the number is 6

count the total number of characters in a file

Leave a Comment