The input() function takes input from the user and returns it.
Example
input() Syntax
The syntax of input() function is:
input([prompt])
input() Parameters
The input() function takes a single optional argument:
- prompt (Optional) - a string that is written to standard output (usually screen) without trailing newline
input() Return Value
The input() function reads a line from the input (usually from the user), converts the line into a string by removing the trailing newline, and returns it.
If EOF is read, it raises an EOFError exception.
Example 1: How input() works in Python?
Output
Python is interesting. The inputted string is: Python is interesting
Example 2: Get input from user with a prompt
Output
Enter a string: Python is interesting. The inputted string is: Python is interesting