title: UnboundLocalError: local variable "tries" referenced before assignment
body: <p>I'm very new to programming and throwing myself in the deep end.
  Trying to write a simple number guessing game, still very rough, but I'm getting an error I'm not sure how to fix.</p>
  
  <p>This is the code:</p>
  
  <p>import random
      guessestaken= 0
      print "You've got to guess a random number between 1 and 20"</p>
  
  <pre><code>def main():
      guessestaken = 0
      number = random.randint(1,20)
      guess = 0
      while guess != number:
  
          print ("Take a guess")
          guess = input("Your guess: ")
          guess = int(guess)
          guessestaken = guessestaken + 1
          if tries is None:
              tries = 0
          tries = tries + 1
  
  
  
          if guess &lt; number:
              print "Too low, try again"
  
          if guess &gt; number:
              print "Too high"
  
  
          if guess is number:
              print "Well done, you guessed the number in ", guessestaken, "guesses."
  
  
  #        if guess != number:
  
  x = 1
  while x is 1:
  #    if tries is 3: break
      guessestaken = 0
      main()
  </code></pre>
  
  <p>And I'm getting this error after:
  UnboundLocalError: local variable 'tries' referenced before assignment, any help would be appreciated.</p>