In this program, we will print the numbers by breaking a loop in Python.
Steps to solve the program
- Use for loop to iterate over numbers from 1-10.
- If a number is not equal to 6 print the number.
- 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