input()

The input() built-in function takes in a value from the user and converts the value into a string.

This function is unique in that the environment creates a field to allow users to enter the value.

Syntax

input()

Example 1

Use input() to prompt user to input a value:

password = input()
print(password)

Example 2

Use input() to prompt user to input a value based on a message:

username = input("What is your name?")
print(username)
Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy