w3resource

Python: input() function

input() function

The input() function allows user input. If the prompt argument is present, it is written to standard output without a trailing newline.

The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, EOFError is raised.

Version:

(Python 3.2.5)

Syntax:

input([prompt])

Parameter:

Name Description Required /
Optional
prompt A string that is written to standard output without trailing newline. Optional

Example: Python input() function

inputStr = input('Enter a string:')

print('The inputted string is:', inputStr)

Output:

Enter a string: Python input() Example
The inputted string is: Python input() Example

Pictorial Presentation:

Python: Built-in-function - input() function

Python Code Editor:

Previous: id()
Next: int()

Test your Python skills with w3resource's quiz



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python/built-in-function/input.php