How to get user input

Read a line

input() displays an optional prompt, waits for Enter, and always returns a string.

name = input("What is your name? ")
print("Hello,", name)

Convert numeric input

Convert text before doing arithmetic. int() accepts whole-number text; invalid input raises ValueError.

age_text = input("How old are you? ")
age = int(age_text)
print("Next year you will be", age + 1)

Build readable output

An f-string places expressions inside braces and is often clearer than joining many values with +.

item = input("Item: ")
quantity = int(input("Quantity: "))
print(f"You ordered {quantity} {item}.")

Validate before converting

Real programs should expect mistakes. A loop can ask again until the user enters digits; later, exception handling will support more formats.

text = input("Enter a whole number: ")
while not text.isdigit():
    text = input("Digits only; try again: ")
print(int(text) * 2)