Practice Challenge: Three Questions with Python input()

input(), int(), and choosing which answers actually need converting — all at once.

  • Lesson 4 of 5
  • PRO
  • Ages 10+
  • 3 hands-on levels
See what PRO unlocksA one-time $49.99 purchase. Topics 1–3 are free.

The dragon explains

The Dragon's Three Questions

  1. The dragon: You've learned three things about talking to the player. Let's put them together.

  2. The dragon: One: input() asks and really waits for an answer, which always arrives as text.

  3. The dragon: Two: int() converts that text into a real number you can do math with.

  4. The dragon: Three: forgetting int() before adding or comparing crashes with a real TypeError — Python's honest way of saying 'this is still text'.

  5. The dragon: The challenge ahead asks three questions. Some answers need int(), one doesn't — figuring out which is the whole point.

Quick check

Check your understanding

Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.

  1. Question 1 of 1

    You ask for a player's NAME with input(). Do you need int() before printing it?

    question.pyPython 3
    name = input("Name? ")print(name)
    • No — you only need int() when you're going to do MATH with the answerCorrect
    • Yes — every input() answer needs int() before you can use it

    Why: No int() needed here — a name is used as text, not a number. int() only matters when you're about to do math with the answer.

In the game

What you'll practice

Three levels in the game: one guided first try with the shape of the answer already there, then two to solve on your own.

  1. 1

    GuidedYour first try

    Ask "How many gems? " and print TREASURE! if the number is 10 or more, otherwise print KEEP LOOKING. The player will type 15.

  2. +2

    PracticeTwo more, on your own

This lesson is part of PRO.

PRO is a one-time $49.99 purchase, no subscription, and unlocks this whole topic along with everything else. Topics 1–3 are free, start to finish.

Unlock this lesson with PRO

Stuck three times? The game offers the answer — unasked.