Home › Python with Chai › Lesson 8

input: ask the customer

Python with Chai, lesson 8 of 20. A short Hinglish video, simple English notes and code you can run, free.

Open the interactive lesson with Run button

The idea

input() pauses the program and waits for the user to type an answer.

input always gives you text. If you need a number, wrap it in int().

Without int, "3" * 20 writes "3" twenty times instead of giving 60.

The code

naam = input("Naam? ")
print("Namaste", naam)

cups = int(input("Kitne cup? "))
print("Bill:", cups * 20)

Output:

Naam? Raj
Namaste Raj
Kitne cup? 3
Bill: 60

Try it yourself

Remember

input lets your program talk to people.

← Mini project: the chai bill · try-except: explain, don't crash →

All lessons: Python with Chai