python hide input

from getpass import getpass
password = getpass()

Here is what the above code is Doing:
1. We’re importing the getpass module.
2. We’re assigning the value of the getpass() function to a variable called password.
3. We’re printing the value of the password variable.