English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The input() method reads a line from input, converts it to a string, and returns it.
The syntax of the input() method is:
input([prompt])
The input() method takes an optional parameter:
prompt (optional) -Write a string to standard output (usually the screen) without a newline character
The input() method reads a line from input (usually user input), converts it to a string by removing the trailing newline character, and then returns it.
If EOF is read, EOFError exception will be raised.
# Get user input inputString = input() print('The input string is:', inputString)
When running the program, the output is:
www.oldtoolbag.com The input string is: www.oldtoolbag.com
# Get user input inputString = input('Input string:') print('The user input string is:', inputString)
When running the program, the output is:
Input string:www.oldtoolbag.com Python Basic Tutorial The user input string is: www.oldtoolbag.com Python Basic Tutorial