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 Code Editor:
Test your Python skills with w3resource's quiz
Python: Tips of the Day
How do I check if a list is empty?
For example, if passed the following:
a = [] if not a: print("List is empty")
Ref: https://bit.ly/2A4JXx9
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework