KIIT Polytechnic logo Students Hub KIIT Polytechnic साइन इन
▲बोर्ड ◆नोट्स ≡सिलेबस ▦टाइमटेबल ?डाउट ▶रील्स 🎮सीखें 🐍कोर्स ◈मौके ✍ब्लॉग ▮स्टोर ★टीम ⌕खोजें
← Learn to Code — Python for Beginners मॉड्यूल · Storing Information

Getting input from the user

So far your programs only ever do the same thing. input() lets a program ask a question and wait for an answer — try the starter code below, it will actually pop up a real prompt box.

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

Whatever gets typed is stored in name as text. The + here glues two pieces of text together — this is called concatenation.

One catch: input() always gives you text, even if someone types a number. If you need to do maths with it, convert it first using int():

age = input("How old are you? ")
age = int(age)
print(age + 1)