input()

Ask the user to type something. The answer always comes back as text.

Syntax

answer = input(prompt)
  • Convert the text with int() or float() when you need a number.

Example

name = input("Name? ")
print("Hi", name)

Output:

Name? Pip
Hi Pip

Common mistakes

  • input() returns a string even when the user types digits: input() + 1 is a TypeError.
  • On this site, lessons give the program its answers, so input() never waits.

Practise it