Python Loops Flashcards
1
Q
When is a break statement used ?
A
When you want to stop looping over a problem once a condition is met
for example
x = 1
while 1==1:
print(x)
x+=1
if x >5:
print(“breaking”)
break
print(“Coded Ended”)
output -
1
2
3
4
5
breaking
Coded Ended