break is used to stop the loop immediately.
example
i = 1
while i <= 5:
if i == 3:
break
print(i)
i += 1output
1
2Note
breakexits the loop immediately- Loop stops even if the condition is still
True
<< Python While Loop | Python Continue >>