Menu
Coddy logo textTech

Input

Part of the Fundamentals section of Coddy's Python journey — lesson 26 of 77.

As of now we stored values that we thought about in variables. Programs usually don't work this way. We receive values from an outer source, a user for example.

To get input from a user or the system we need to write:

var = input()

This will store the input in the variable var.

The input is always of type string. For example, if the input is 56 then var will hold the string "56".

challenge icon

Challenge

Beginner

Write a program that get input from the user (their name), and then outputs Hello, followed by a space and the user's inputted name.

For example, if the user inputs Bob, the expected output is Hello, Bob.

You will need to:

  1. Use input() to get input from the user.
  2. Store the input in a variable.
  3. Print Hello, and the stored variable in the end (add a space after the comma).

Cheat sheet

To get input from a user:

var = input()

The input is always stored as a string, even for numbers.

To print a greeting with the input:

name = input()
print("Hello, " + name)

Try it yourself

# Write code here
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals