Basic Input
The input() function reads a line of text from the user. It always returns a string, no matter what the user types. The optional prompt string is displayed to the user.
name = input("What is your name? ")
print(f"Hello, {name}!")
Try it Yourself โ
Getting Numbers from Input
Since input() returns a string, you need to convert it to a number if you want to do math. Use int() or float() to convert.
age_str = input("How old are you? ")
age = int(age_str)
print(f"Next year you'll be {age + 1}")
Try it Yourself โ