Search notes:

Python: input

input() reads a line from stdin and returns it:
The following example prompts the user to enter his/her name and password and assigns the values to two variables.
username = input('Username: ')
password = input('Password: ')

if username == 'Rene' and password == 'secretGarden':
   print('Bingo')
else:
   print('Wrong username or password')
Github repository about-Python, path: /built-in/functions/input/demo.py

Reading passwords

When using input, the value that the user enters is displayed on the console. This is not always desired, especially when entering passwords. In order to hide the entered value, the function getpass(), found in the equally named standard library module getpass can be used:
from getpass import getpass

username = input  ('Username: ')
password = getpass('Password: ')

if username == 'Rene' and password == 'secretGarden':
   print('Bingo')
else:
   print('Wrong username or password')
Github repository about-Python, path: /built-in/functions/input/password.py

See also

Python: Built in functions

Index