break
noun
say it: “BRAYK” /ˈbreɪk/
A Python keyword that stops a loop at once, even if items are left.
What does break do?
break stops a loop immediately, even if there are items left.
for item in ["socks", "keys", "phone"]:
if item == "keys":
print("Found the keys!")
break
In a sentence
- “The menu loop runs until the user types q, and then break leaves it.”
- “Once the keys were found, break ended the search.”
Level: Apprentice · More Python terms at this level
Updated