title: Python login counter
body: <p>I'm new to Python and am trying to create a simple login with a faux OTP system and login limiter. The OTP works, but the counter for the login limiter doesn't. It gives me the desired result after only one failed attempt (I want 3). The output after a failed attempt is:</p>
  
  <p>ACCESS LOCKED. YOU DON'T DESERVE TO SEE WHAT'S HERE. GOODBYE.</p>
  
  <p>Incorrect Username or Password. Please try again.</p>
  
  <p>Incorrect Username or Password. Please try again.</p>
  
  <p>Incorrect Username or Password. Please try again.</p>
  
  <p>Process finished with exit code 1</p>
  
  <p>Here's the code:</p>
  
  <pre><code>def old_acc():
  count = 0  # count created to limit number of failed logins
  login = input("Username:    ")  # prompts user to login in with their username
  pw = input("Password:   ")  # prompts user to login in with their password
  while count &lt;= 3:
      for line in open("db.txt", "r").readlines():
          acc_info = line.split()
  
          # if username and pw do not match, prompt user to try again
          if login != acc_info[0] and pw != acc_info[1]:
              print("\nIncorrect Username or Password. Please try again.\n")
              count += 1
          # if username and pw match, login is successful; generate otp
          else:
              gen_otp()
              print("ACCESS GRANTED")
              access_info()
  
          # if failure count is = 3, deny access and lock out.
          if count == 3:
              # stops code and doesn't allow any further input.
              sys.exit("ACCESS LOCKED. YOU DON'T DESERVE TO SEE WHAT'S HERE. GOODBYE.")
  </code></pre>
  
  <p>Here's the code for the OTP generation, for reference.</p>
  
  <pre><code>def gen_otp():
      digits = "0123456789"  # digits for OTP generation
      otp = ""
  
      for i in range(4):
          otp += digits[math.floor(random.random() * 10)]
      mbox("Enter OTP", otp, 1)  # gives user message with OTP
      otp_input = input("Enter OTP:   ")
  
      if otp == otp_input:
          print("ACCESS GRANTED")
          access_info()
  
      return otp
  </code></pre>
  
  <p>Thanks.</p>