Input in Python is carried out using the input statement. When used in a program, this will let the user input some text. This text can then be assigned to a variable.


If you write input('Enter your name: ') then it will ask the user to enter their name, but their name will not be saved to use later in the program. Instead use name = input('Please enter your name').

Easy example

name = input('Enter your name: ')
Show/Hide Output
Enter your name

Whatever text is entered by the user is assigned to the variable name.


variableName = input(string)


Example 1 - Input to pause a program

Show/Hide Output

The program pauses and will continue when the return or enter key is pressed.

Example 2 - Input statement which also outputs text

input('Press return to continue...')
Show/Hide Output
Press return to continue...

Example 3 - Storing user input in a variable

name = input('What is your name? ')
print('Hello ' + name)
Show/Hide Output
What is your name? Tim
Hello Tim

Key points


Don’t use a space with the input statment. It should be written as input() not input ().


name = input('Enter your name') will not have a space before they enter their name. Instead use name = input('Enter your name: ')