title: how do i reset the random number generator python with minimal changes
body: <p>my assignment for school is trying to make a game with the following rules:
  Create a program that randomly generates a number from 1 - 50. the user has to guess the number. When they guess,i should comment to help the user guess. Once they get the number i should tell the user how many guesses it took and ask the user if they would like to play again. If they do, create another number, if they do not, end the program.</p>
  
  <p>my problem is that when i play again, my guess count doesnt reset and my"random number" doesnt change, please include a explanation of the changes for my code because im in a grade 11 course and just started learning to code, so im very new to this, thanks!
  there is the codes:</p>
  
  <pre><code>import random
  ran=random.randrange(1,50)
  counter=0
  guessed=False
  
  def startgame():
      answer=input("would you like to play a game? enter 'yes' or 'no'")
      if answer == "yes":
          while guessed != True:
              game()
      if answer=="no":
          print("thanks for playing")
  
  def game():
      global counter
      counter=counter+1
      x=input("chose a number between 0 and 50")
      if int(x)&gt;ran:
          print("your value is too high")
      elif int(x)&lt;ran&lt;50:
          print("your value is too low")
      elif int(x)==ran:
          guessed=True
          answer=input("that is correct! it took you "+ str(counter) +" tries,     "+"would you like to play again? enter 'yes' or 'no'")
          if answer == "yes":
              main()
          if answer=="no":
              print("thanks for playing")
  
  def main():
      startgame()
  
  if __name__ == '__main__':
      main()
  </code></pre>