title: How to end program if input == "quit" with many if statements?
body: <p>I want the user to be able to quit this program at any point by typing in "quit".</p>
  
  <p>Is there a way to do this with one instance of a break statement, or do I need to add a break to every "if y ==" statement in my code?   </p>
  
  <pre><code>fruits = []
  notfruits = []
  print(fruits)
  print(notfruits)
  
  while len(fruits) &lt; 3 or len(notfruits) &lt; 3:   # replaced `and` with `or`
      print("Please enter fruits or notfruits:") #
      y = str(input(": "))                       # moved the input here
      if y == "fruits":
          while len(fruits) &lt; 3:
              x = str(input(": "))
              x = x.strip()
              if x in notfruits:
                  print(x + " is not a fruit!")
              elif x in fruits:
                  print(x + " is already in the list!")
              else:
                  fruits.append(x)
                  print(fruits)
      elif y == "notfruits":
           while len(notfruits) &lt; 3:
              x = str(input(": "))
              x = x.strip()
              if x in fruits:
                  print(x + " is a fruit!")
              elif x in notfruits:
                  print(x + " is already in the list!")
              else:
                  notfruits.append(x)
                  print(notfruits)
      elif y == "clearfruits":
          del fruits[:]
      elif y == "clearnotfruits":
          del notfruits[:]
      elif y == "quit":
          break
      else:
          print("Not a valid option!")
  </code></pre>