title: Python How to stop a loop with an user input
body: <p>This is probably a simple answer but I thought I'd ask anyway.</p>
  
  <p>My code below is asking the user for a number and depending on the answer provided will print the grade that corresponds with the numbers. </p>
  
  <p>I want to stop the loop (terminate the program) by having the user type in (999). I know the problem is in my <code>if userScore &gt;= 90" print ('A')</code>. So when the user enters the 999, the computer takes it as an A. </p>
  
  <p>Is there a shortcut to fix this?</p>
  
  <p>(PS I added the breaks to every line because when they were not there the outputs kept repeating endlessly.)</p>
  
  <pre><code>    userScore = float(input('Enter the score or type "999" to quit: '))
  
      while True:
  
          try:
              if userScore &gt;= 90:
                  print ("You earned an A")
                  break
  
  
              elif userScore &gt;= 80:
                  print ("You earned a B")
                  break
  
  
              elif userScore &gt;= 70:
                  print ("You earned a C")
                  break
  
  
              elif userScore &gt;= 60:
                  print ("You earned a D")
                  break
  
  
              elif userScore &lt;= 59.9:
                  print ("You earned an F")
                  break
  
          except:
              if userScore == '999':
                  break
            main()
  </code></pre>