Module 5 of 15 · Step 1 of 10

User Input

input() lets a program receive a value while it runs. The Program input box supplies those values in these lessons; each line is used by the next input() call.

By the end of this lesson, you can:
  • Read text with input()
  • Understand that input returns str
  • Convert whole-number and decimal input
  • Use multiple input values in order
Input lesson progress0%

Course progress: 0% · 0 of 10 steps completed in this module

Learn · Read one answer
Concept 1 of 4

Read one answer

input() takes one line from Program input and returns it as text. You may include a prompt in parentheses to explain the question; the browser's Program input box supplies the answer.

Pattern
name = input("Your name: ")
Code
name = input("Your name: ")
print("Hello,", name)
Output
Hello, Maya

Why it works

  1. The input call reads Maya from Program input.
  2. name stores that text.
  3. print combines the greeting and name with a space.

Common mistake

Not this
name = "input()"
Try this
name = input()

Quotes make the literal text input() rather than reading a value.