When a loop should stop at a meaningful condition, use break to terminate the innermost enclosing loop immediately. A common pattern starts with while True and exits after a successful guess or an empty order. section 1.3 section 4.4
Stop a guessing loop
Choose an answer with random.randint, repeatedly read the user's input, convert it with int, and compare it with the answer. When the guess is correct, break exits the loop. The same control-flow shape supports a menu-ordering program: strip the input, use if not order for empty input, and break before processing further. section 1.3 section 4.4
Use break when:
- A sentinel condition signals that repeated interaction is finished. section 4.4
- A successful search or comparison makes further iterations unnecessary. section 1.3






