Labs ICT
โญ Pro Login

User Input

1 min read | Python Tutorial
โญ

Want the full learning experience?

Get structured courses, certificates, projects, and instructor support with LabsICT Pro.

Explore Pro Courses

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}!")

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}")

๐Ÿงช Quick Quiz

What data type does input() always return?