Lesson 4 of 34

input(): Asking the User

8 min 20 XP

input() reads what the user types. Here, before you press Run, type the values in the Input box, one per line.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

input() always gives you a string. To use it as a number, write int(input()).

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Each input() reads the next line of the Input box.

Challenge

+20 XP

Read two numbers with input() and print their sum. The Input box has 5 and 7, so the answer should be 12.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.