Jason Moore
Jason Moore

Reputation: 259

Python: Display input as "*"

I am not very familiar with Python at all, and I am trying to do some basic tasks.
I want a user to input text, but I want it to appear as a "*". I am unsure of how to do this, and haven't come across a solution.

x = input("Input to appear normally: ")
y = input("I want this to appear as ******: ")

I have no idea what so ever on how to do this.
I will be very thankful for help.
Thanks!

Upvotes: 3

Views: 918

Answers (1)

syntagma
syntagma

Reputation: 24304

You can use:

import getpass

pswd = getpass.getpass('Password:')

And if you want to display input as "*", this answer explains how to do it.

Upvotes: 5

Related Questions