title: How to have password echoed as asterisks
body: <p>I'm trying make a login window where a user is prompted to enter their Username and Password, although when the password is entered I am looking for asterisks to be printed, like common password entry (i.e. - Sekr3t is echo'd as: * * * * * *).</p>
  <p>Here's the code I have so far, and I can't figure out why it doesn't echo asterisks:</p>
  <pre><code>import msvcrt
  import sys
  
  def login(prompt = '&gt; '):
     write = sys.stdout.write
     
     for x in prompt:
         msvcrt.putch(x)
     passw = &quot;&quot;
     
     while 1:
         x = msvcrt.getch()
         if x == '\r' or x == '\n':
             break
         if x == '\b':
             # position of my error
             passw = passw[:-1]
         else:
             write('*')
             passw = passw + x
     msvcrt.putch('\r')
     msvcrt.putch('\n')
     return passw
  </code></pre>
  <blockquote>
  </blockquote>
  <p>Any help would be appreciated.</p>