Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links



How to hide user input for password in Python

15 January,2022 by Rambler

Question: How do I hide user input for a password entry using Python?   So instead of  the password displaying as the user types the password , the screen wouldn't change.

Answer: There is the getpass() function , which comes as standard part of the Python Library . From the Python documentation:  "Prompt the user for a password without echoing. The user is prompted using the string prompt, which defaults to 'Password: '"

import getpass

password = getpass.getpass()

Author: Rambler (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How to hide user input for password in Python