Search code examples
pythonpython-3.xinputpasswordsgetpass

Getting password using getPass isn't working for me


My code :

from getpass import getpass
def display_credentials():
    website = input("Enter the name of the website:")
    password = getpass("Enter master password: ")
    print(website)
    print(password)

if __name__ == "__main__":
    display_credentials()

Output: Enter the name of the website:yahoo

Question: The next line does not get executed at all. Not sure what's the error here. I want the next line to be executed(asking password) after I input the name of website.


Solution

  • It's working in console.

    May be the problem you have is that you are launching it via PyCharm or any other IDE, which has it's own console (and is not the console used by getpass)

    Running the code via a command prompt should work