Examples of break and continue statements in Python programming
All Contributions
this exerice to practice on using the break statement
write a program that keep asking user to enter any thing in keyboard untill user enters the word 'quit'
while True:
s = input('Enter something : ')
if s == 'quit':
break
print('Length of the string is', len(s))
print('Done')
Continue inside nested-loop :
for i in range(4):
for j in range(4):
if j==2:
continue
print("The number is ",i,j);
Continue inside while-loop :
ignore printing the number 7
i = 0
while i <= 10:
if i == 7:
i += 1
continue
print("The Number is :" , i)
i += 1
output:
The Number is : 0
The Number is : 1
The Number is : 2
The Number is : 3
The Number is : 4
The Number is : 5
The Number is : 6
The Number is : 8
The Number is : 9
The Number is : 10
total contributions (11)
this exerice to practice on using the break statement
write a program that keep asking user to enter any thing in keyboard untill user enters the word 'quit'