Chapter 6b - Break
Break Statementโ
for i in range(100):
print(i)
if(i==8):
break
- Note how it stops when i==8
- What happens if you delete the:
if(i==8):
break
?
Minerโ
The following program
for i in range(1,8):
print("\nEntering tunnel " + str(i))
response = input("Enter Yes if diamonds are in this tunnel and No otherwise ")
response = response.lower()
if response == 'yes':
print('Diamonds found after searching ' + str(i) + ' mines')
print('Search stops here')
break