I'm making a program where the user needs to enter a password. I'm using the input function for this. How would I make it so that the user sees *** symbols instead of the actual letters for their password?
Asked
Active
Viewed 138 times
2
-
2Hi there, take a look to [this](https://stackoverflow.com/questions/27631629/masking-user-input-in-python-with-asterisks) question. It may help. – dcg Dec 28 '17 at 16:17
-
You using a gui or what? This thing called mask.Plz be more explicit – Ευάγγελος Γρηγορόπουλος Dec 28 '17 at 16:18
-
BTW, you generally should not define functions inside other functions, unless you have a good reason to do that. – PM 2Ring Dec 28 '17 at 16:30
-
Please don't post screenshots of code. – Donald Duck Dec 28 '17 at 17:06
2 Answers
0
You can use getpass module to hide the password entered on the console.

bboumend
- 490
- 3
- 13
-
Sure, but `getpass` isn't _guaranteed_ to hide the password: "If echo free input is unavailable `getpass()` falls back to printing a warning message to stream and reading from `sys.stdin` and issuing a `GetPassWarning`." – PM 2Ring Dec 28 '17 at 16:28
-1
You can use a function like below
import getpass
pswd = getpass.getpass('Password:')

clinomaniac
- 2,200
- 2
- 17
- 22