title: 4 Digit Guessing Game Python
body: <p>Im trying to make a 4 digit numbers guessing game in Python 3. It should work by generating a random number between 1000 and 10000 (random.range(1000,10000)) and then by the user guessing and it should return after each guess how many numbers you have got right. My code doesn't exactly work and, I can't think why it doesn't so help is appreciated. </p>
  
  <pre><code>import random as r
  
  guessing = True
  real_ans = r.randrange(1000, 10000, 2)
  real_ans_str = str(real_ans)
  
  correct = 0
  
  class Player():
      def __init__(self):
          self.player_guess = input("Enter a guess")
          self.evaluate(correct)
      def evaluate(self, correct):
          for n in range(3):
              if self.player_guess[n] == real_ans_str[n]:
                  correct += 1
          if not correct == 4:
              print(str(correct)," was correct")
              correct = 0
          else:
              print("You guessed it! ")
              guessing = False
  
  while guessing:
      Player()
  </code></pre>