-1

I am requesting user input. I am asking for username then password. EG

username = input('Please enter a Username:\n')
password = input('Please enter a Password:\n')

When run this will of course appear like this:

Please enter a Username:
Iain
Please enter a Password:
Iain

What I want is this:

Please enter a Username:
Iain
Please enter a Password:
****
Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
IGDB
  • 1
  • 1
  • 1
    I suggested `getpass` but that hides input, not replace it with stars. – Jack Deeth Feb 10 '22 at 21:04
  • You will like to [rewrite the last line(s) of the console](https://stackoverflow.com/questions/6840420/rewrite-multiple-lines-in-the-console) and then print the stars. – Banana Feb 10 '22 at 21:24
  • Does this answer your question? [How do I convert a password into asterisks while it is being entered?](https://stackoverflow.com/questions/35805078/how-do-i-convert-a-password-into-asterisks-while-it-is-being-entered) Please search to see if your question has already been asked and answered before asking a new question. – Pranav Hosangadi Feb 11 '22 at 00:06

1 Answers1

1

You can use a library called pwinput.

You can install it using pip: pip3 install pwinput.

And use it as follows:

import pwinput
password = pwinput.pwinput()

This would open a prompt like this:

Password: ****

If you want to remove the text 'Password:', you can do:

password = pwinput.pwinput(prompt='')
Agni
  • 57
  • 4