All lessons

Reading Input

7 min · Python

Make your program read the numbers and text it is given, instead of typing them into the code.

Python · Reading Input0/5 cleared

Enemy 1 of 5

So far every value in your programs was typed straight into the code. Real problems do not work that way. A problem hands your program some input, and your program has to read it.

In Python you read one line of input with input(). It gives the line back to you as text, and you store it in a variable like any other value.

The Input box under this text holds the line your program will receive. Press Run and the program greets whoever is in the input.

You
Cold-Start Frostling

Input your program receives

Ada
Loading editor…
Target output: Hello, Ada

Stuck? Ask Rena

Your AI tutor. Hints, not answers.

Asking for help is part of coding. Rena reads your code and gives you a hint. She is free with an account: 20 hints a day.