THE WORLD'S LARGEST WEB DEVELOPER SITE

Python input() Function

❮ Built-in Functions


Example

Ask for the user's name and print it:

print('Enter your name:')
x = input()
print('Hello, ' + x)
Run example »

Definition and Usage

The input() function allows user input.


Syntax

input(prompt)

Parameter Values

Parameter Description
prompt A String, representing a default message before the input.

More Examples

Example

Use the prompt parameter to write a message before the input:

x = input('Enter your name:')
print('Hello, ' + x)
Run example »

❮ Built-in Functions