Python Tutorial – Input


Python’s Input Function ✈️

In Python, you can use the input(prompt) function to receive user input and store it in a variable, and you can use the "prompt" parameter as a prompt message before input.

Example

input('Please enter your name:')

Result

Please enter your name:
You can type "HelloWolrd" after the ":" and press Enter.

Example

pwd = input('Please enter your password:')
print(f'Password is:{pwd}')

Result

Please enter your password:
Password is:12345

Process finished with exit code 0
You can type "12345" after ":" and press Enter to see "Password is:12345".

The Type of Data Received By Input

Add "print(type(pwd))" to the previous example to check the type of pwd.
pwd = input('Please enter your password:')
print(f'Password is:{pwd}')

print(type(pwd))

Result

Please enter your password:12345
Password is:12345
<class 'str'>

Process finished with exit code 0
You can know that the pwd storage type is "str" string type.