title: How do you start a Python game loop?
body: <p>I have this very simple console game and I would like to restart the loop after the user answers a question but something doesn't seem to work properly.</p>
  <pre><code>import random
  
  random_number = random.randrange(0, 500)
  chosen_number = int(input(&quot;Please pick a number: &quot;))
  gameOn = 1
  
  while gameOn == 1:
      if chosen_number == 500 or chosen_number &lt;= 0 :
          print(&quot;Number must be below 500 and above 0.&quot;)
          print(random_number)
          chosen_number = int(input(&quot;Please pick a number: &quot;))
          continue
      if chosen_number &gt; random_number:
            print(&quot;Too high&quot;)
            chosen_number = int(input(&quot;Please pick a number: &quot;))
      elif chosen_number &lt; random_number: 
            print(&quot;Too low&quot;)
            chosen_number = int(input(&quot;Please pick a number: &quot;))
      else:
          print(&quot;Congratulations, you guessed right. The number was &quot; + str(chosen_number) + &quot;.&quot;)
          break
  
      answer = input(&quot;Do you want to play again? Y/N &quot;)
  
      if answer == &quot;Y&quot; or &quot;y&quot; or &quot;yes&quot;:
          gameOn = 0
      else:
          print(&quot;Goodbye!&quot;)
  </code></pre>