CurriculumPython input() and Type Conversion for KidsWhat happens if you forget int()

Fixing a Python TypeError from input() and Text Addition

Text plus a number is a real Python crash — and the error tells you exactly what went wrong.

Lesson 3 of 5PROAges 10+
See what PRO unlocks →

What happens if you forget int()

You've seen int() convert text into a number. Now let's see what happens if you forget it.

input() ALWAYS returns text. Try to add a number to it directly, and Python stops you.

health = input("Health? ")
print(health + 10)

Python raises a TypeError — something like "can only concatenate str (not int) to str". That error is Python's honest way of saying: this is still text, not a number.

The fix is exactly what you already know: wrap it in int() before doing any math with it.

Check your understanding

health = input("Health? "), and the player types 50. What happens when you run print(health + 10)?

health = input("Health? ")
print(health + 10)
  • A TypeError — health is still text, not a number
  • It prints 60

Why: A TypeError. health holds text, even though the player typed digits — and Python refuses to add text and a number without you converting first.

What actually fixes the crash from the last question?

  • Wrapping health in int() before adding: int(health) + 10
  • Nothing — the crash means Python is broken

Why: int(health) + 10 fixes it — converting first turns health into a real number Python can add to.

What you'll practice

This code asks "How much health? " and tries to add 10 to it — but it crashes with a TypeError. Run it once to see the real error, then fix it by converting the answer with int() before adding.

Unlock this lesson with PRO →

More from this topic

What happens if you forget int() is one lesson inside Python input() and Type Conversion for Kids — see the full lesson order and what the whole topic covers.

View the full topic →