Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Display input as "*"

Tags:

python

input

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!

like image 854
Jason Moore Avatar asked Nov 19 '25 03:11

Jason Moore


1 Answers

You can use:

import getpass

pswd = getpass.getpass('Password:')

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

like image 82
syntagma Avatar answered Nov 20 '25 16:11

syntagma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!