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)
Try it Yourself »

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)
Try it Yourself »

❮ Built-in Functions

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.