input() shows a message, waits for the user to type something and press Enter, and gives you back what they typed.
The program
python
name = input("Enter your name: ") print(f"Hello, {name}!")
Typed in this example: Ada. Press Run to type your own.
output
Enter your name: Ada Hello, Ada!
How it works
- The text inside
input(...)is the prompt: the message the user sees. - Whatever the user types comes back as a string, even if they type digits.
Numbers from input
Because input() always gives you a string, convert it before you do maths with it. Use int() for whole numbers and float() for numbers with a decimal point:
python
age = int(input("How old are you? ")) print(f"In ten years you will be {age + 10}.")
Typed in this example: 25. Press Run to type your own.
output
How old are you? 25 In ten years you will be 35.
If the user types something that is not a number, such as twenty, int() raises a ValueError. The ValueError page shows how to handle that.