The input () function in Python
Python's built-in input () function allows users to enter data, convert it into a string, and return the entered content.
Input function syntax ()
input([prompt])
Parameter of input function ()
input () has a unique parameter:
prompt
: is a string entered by the user.
For example
1. Input () method works in Python
# nhận input từ người dùng inputChuoi = input() print('Chuỗi đầu vào là:', inputChuoi)
Suppose the input user input is "Website TipsMake.com". Run the program, the result is:
Website TipsMake.com Chuỗi đầu vào là: Website TipsMake.com
2. Receive input from user with prompt before entering.
# nhận input từ người dùng inputChuoi = input('Nhập chuỗi:') print('Chuỗi đầu vào là:', inputChuoi)
Result:
Nhập chuỗi: Website TipsMake.com Chuỗi đầu vào là: Website TipsMake.com
See also: Built-in Python functions
4.3 ★ | 3 Vote
You should read it
May be interested
- Type () function in Pythonthe built-in function type () in python returns the type of object passed as parameter.
- Print () function in Pythonthe print () function in python works to display the screen magic when the program executes.
- Sum () function in Pythonthe built-in function sum () in python returns the sum of all numbers in iterable.
- __Import __ () function in Python__import __ () is an advanced function called by the import statement in python
- The function hasattr () in Pythonthe hasattr () function in python is used to check if the input object has the property you want to find.
- Filter () function in Pythonhow is the filter () function syntax, what parameters and how does it work? invites you to read the track.