You can use break to get out of a loop. Your code also has some other errors, which I've fixedd. Try this:

full_name = input ('Enter a customers name (or q to quit): ')
if full_name == 'q':
  exit()
address = input ("Enter the customer's address: ")
location = input("Enter customer's city, state, and zip code: " )

text = ''
while text.lower() != 'q':
  thin_M = int(input('Enter the number of Thin Mints: '))
  if thin_M > 10:
    print ('Sorry we are accepting a maximum of 10 boxes per type.')
  else:
    break  
Answer from Michael M. on Stack Overflow
🌐
W3Schools
w3schools.com › Python › python_for_loops.asp
Python For Loops
The for loop does not require an indexing variable to set beforehand. Even strings are iterable objects, they contain a sequence of characters: ... fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) if x == "banana": break Try it Yourself » · Exit the loop when x is "banana", ...
Discussions

How does python know where the end of a for-loop code block is? There's no indication of when execution should restart.
Mark Miller is having issues with: I can't use "continue" or "break" because the code block should execute for each item, and then break when no further items are available. The c... More on teamtreehouse.com
🌐 teamtreehouse.com
1
February 3, 2017
Breaking/continuing out of multiple loops - Ideas - Discussions on Python.org
Hi! SUGGESTION An easy way to break/continue within nested loops. MY REAL LIFE EXAMPLE I am looping through a list of basketball players, each of which has multiple tables, each of which can have up to three different versions. I manipulate data in the deepest loop and, if some key data is ... More on discuss.python.org
🌐 discuss.python.org
4
August 21, 2022
How can I exit a loop in Python when a certain condition is met? - Ask a Question - TestMu AI Community
How can I exit a loop in Python when a certain condition is met? I have a loop, and I want it to stop when x + y = z. Here’s my code: from random import randint import os x = randint(1, 11) y = randint(1, 11) print("… More on community.testmuai.com
🌐 community.testmuai.com
0
December 2, 2024
How do I end a For or While loop without using break?
A for loop ends when it exhausts its iterable, and a while loop terminates when its condition is no longer met. If you were going to write while True: if some_variable == "some value": break #do stuff then instead you could write: while some_variable != "some value": #do stuff More on reddit.com
🌐 r/learnpython
4
4
March 19, 2022
🌐
Enki
enki.com › post › how-to-exit-a-loop-in-python
Enki | Blog - How to Exit a Loop in Python
Learn to manage loops effectively in Python using the break statement to exit for and while loops under specific conditions, optimizing code efficiency.
🌐
Coursera
coursera.org › tutorials › python-break
How to Use Python Break | Coursera
When working with loops, remember that indentation tells Python which statements are inside the loop and which are outside the loop. Your break statement should follow your if statement and be indented.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3
How To Use break, continue, and pass Statements in Python | DigitalOcean
April 24, 2026 - The break statement allows you to exit a loop entirely when a specific condition is met, effectively stopping the loop execution. The continue statement lets you skip the rest of the code inside the loop for the current iteration and move on to the next iteration.
Find elsewhere
🌐
Mimo
mimo.org › glossary › python › break-statement
Mimo: The coding platform you need to learn Web Development, Python, and more.
This simple yet powerful control structure is especially useful for optimizing loop behavior, avoiding unnecessary iterations, and writing more efficient and readable code. The break statement in Python is used to immediately exit a loop—either a for loop or a while loop—before the loop ...
🌐
Python Software Foundation
wiki.python.org › python › ForLoop.html
For loops - Python Wiki
Like the while loop, the for loop can be made to exit before the given object is finished. This is done using the break statement, which will immediately drop out of the loop and continue execution at the first statement after the block.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-break-statement
Python Break Statement - GeeksforGeeks
The break statement in Python is used to immediately terminate a for or while loop when a specified condition is met. After the loop exits, program execution continues with the next statement following the loop.
Published   June 5, 2026
🌐
Manifoldapp
cuny.manifoldapp.org › read › how-to-code-in-python-3 › section › 8adf4bec-a6ca-4a11-8c8d-4cf4052d5ac4
How To Use Break, Continue, and Pass Statements when Working with Loops | How To Code in Python 3 | Manifold @CUNY
In Python, the break statement provides you with the opportunity to exit out of a loop when an external condition is triggered. You’ll put the break statement within the block of code under your loop statement, usually after a conditional if statement. Let’s look at an example that uses ...
🌐
Medium
medium.com › @pies052022 › python-exit-for-loop-with-example-programs-0b6e97b41318
Python Exit For Loop with Example Programs | by JOKEN VILLANUEVA | Medium
March 2, 2026 - This shows that the break instruction tells the computer to get out of the loop when the integer is equal to 5. In Python, the continue statement allows you to bypass the portion of a loop where an external condition is met while continuing ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › break-continue-and-pass-in-python
Loop Control Statements - Python
July 12, 2025 - # Using For Loop for i in range(5): if i == 3: break # Exit the loop when i is 3 print(i) # Using While Loop i = 0 while i < 5: if i == 3: break # Exit the loop when i is 3 print(i) i += 1 ... Python Continue statement is a loop control statement that forces to execute the next iteration of the loop while skipping the rest of the code inside the loop for the current iteration only, i.e.
🌐
Python.org
discuss.python.org › ideas
Breaking/continuing out of multiple loops - Ideas - Discussions on Python.org
August 21, 2022 - Hi! SUGGESTION An easy way to break/continue within nested loops. MY REAL LIFE EXAMPLE I am looping through a list of basketball players, each of which has multiple tables, each of which can have up to three different versions. I manipulate data in the deepest loop and, if some key data is ...
🌐
Python Morsels
pythonmorsels.com › breaking-out-of-a-loop
Breaking out of a loop - Python Morsels
June 26, 2025 - If you need to break out of your loop entirely, you can use the break statement. If you need to also exit your function early, you could use the return statement. ... The range function can be used for ...
🌐
Python
wiki.python.org › moin › ForLoop
ForLoop
Like the while loop, the for loop can be made to exit before the given object is finished. This is done using the break statement, which will immediately drop out of the loop and continue execution at the first statement after the block.
🌐
TestMu AI Community
community.testmuai.com › ask a question
How can I exit a loop in Python when a certain condition is met? - Ask a Question - TestMu AI Community
December 2, 2024 - How can I exit a loop in Python when a certain condition is met? I have a loop, and I want it to stop when x + y = z. Here’s my code: from random import randint import os x = randint(1, 11) y = randint(1, 11) print("", x, "+", y, "=\n") z = int(input("Resposta=")) if z == x + y: input("\n\nCorreto\nPrima enter para continuar...") else: for z in range(0, 10): os.system('CLS') input("Incorreto.\n\n Tente de novo...") x = randint(1, 11) y = randint(1, 1...
🌐
Python documentation
docs.python.org › 3 › tutorial › controlflow.html
4. More Control Flow Tools — Python 3.14.6 documentation
In either kind of loop, the else clause is not executed if the loop was terminated by a break. Of course, other ways of ending the loop early, such as a return or a raised exception, will also skip execution of the else clause. This is exemplified in the following for loop, which searches for prime numbers:
🌐
Programiz
programiz.com › python-programming › break-continue
Python break and continue (With Examples)
The break statement terminates the loop immediately when it's encountered. ... The above image shows the working of break statements in for and while loops.