Loop control: break, continue, pass
There are 3 so-called loop control keywords: break, continue and pass.
Break
If a break statement is present in the loop, it terminates the loop when a condition is satisfied.
string = 'hello, there'for i in string:
if i == ',':
break
print(i)>>
h
e
l
l
o
In the snippet above, we ask the program to exist as soon as it finds a comma in a string and executes the next statement (which is to print i).