Module 2 · Interaction with the user · Lesson 2 of 6
The result is always a string
Here's the single most important fact about input(), and the one that trips up every beginner: it always returns a string. It doesn't matter what the user types — even if they type digits, you get back text.
Digits in, text out
you type: 123
input() gives you ↓"123"
type: str — not a numberType 123 at the prompt and you don't get the number 123 — you get the string "123". They look identical on screen, but to Python they're completely different things. You can check any value's type with the built-in type() function:
Run it yourselfruns in your browser · Python
main.py
No matter what you enter, type(x) reports <class 'str'>. Keep that in mind — because the moment you try to do arithmetic with it, as the next lesson shows, it matters a lot.