title: Can I improve on the current Python code?
body: <p>I am just starting out with Python and decided to try this little project from <a href="http://en.wikibooks.org/wiki/Python_Programming/Conditional_Statements" rel="nofollow">Python Wiki</a>:</p>
  
  <p><em>Write a password guessing program to keep track of how many times the user has entered the password wrong. If it is more than 3 times, print You have been denied access. and terminate the program. If the password is correct, print You have successfully logged in. and terminate the program.</em></p>
  
  <p>Here's my code. It works but it just doesn't feel right with these <strong>loop breaks</strong> and <strong>nested if statements</strong>.</p>
  
  <pre><code># Password Guessing Program
  # Python 2.7
  
  count = 0
  
  while count &lt; 3:
      password = raw_input('Please enter a password: ')
      if password != 'SecretPassword':
          count = count + 1;
          print 'You have entered invalid password %i times.' % (count)
          if count == 3:
              print 'Access Denied'
              break
      else:
          print 'Access Granted'
          break
  </code></pre>