← All lessons

Input: input()

Sign in · Sign up

Lesson 1.7

The input() function asks the user for a line of text. In the check, the answers are supplied for you — so the task works without a keyboard.

Write a program that:

  1. asks **What is your name? ** (with a space at the end);
  2. prints Hello, <name>!.

For example, if the input is Mia, the result should be:

What is your name? Mia
Hello, Mia!
Hint

input("...") prints the prompt and returns the answer as a string.

First save the answer in a variable, then build the greeting: "Hello, ", the name and "!". The space in the prompt keeps the answer from sticking to the question.