Learn Python
>>> io_formatting.input

Taking Input from the User in Python

#concept

The input() function pauses a program and waits for the user to type something, then returns whatever they typed — always as a string, regardless of what it looks like. That means numeric input needs an explicit conversion, using int() or float(), before it can be used in arithmetic.

#how it works
1

input() displays a prompt and waits

The optional message passed to input() is shown, then the program pauses.

2

The user types and presses Enter

Execution resumes only once Enter is pressed.

3

The result is always a string

Even if the user types 42, input() returns the string "42", not the number.

4

Convert it to use it as a number

Wrap the result in int() or float() before doing arithmetic on it.

5

Multiple calls happen in sequence

Each input() call waits for its own line, one after another.

#example
name = input("What's your name? ")
age = input("How old are you? ")
print(f"Hi {name}, you'll turn {int(age) + 1} next year.")
Output
What's your name? Ada
How old are you? 28
Hi Ada, you'll turn 29 next year.
1input("What's your name? ") displays the prompt, then waits — typing Ada and pressing Enter makes name equal the string "Ada".
2input("How old are you? ") does the same, and age becomes the string "28" — text, not a number, even though it looks like one.
3int(age) + 1 converts "28" to the integer 28 first, then adds 1, giving 29.
4The f-string combines everything into the final printed message.
#use cases
Building simple command-line tools that ask the user for information
Prompting for configuration values, like a filename or a threshold
Simple quizzes or interactive scripts run directly in a terminal
Validating input in a loop until the user provides something usable

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in Python yourself — building beats watching.