input(): let the player type back
So far your program does the talking. input() lets it listen — it pauses, waits for the player to type, and hands you back whatever they wrote.
The big idea
input() waits for the player to type something, then gives that text back to your program.
See it in code
input() makes your program listen. It pauses, waits for the player to type, and hands back whatever they wrote. Here we ask for a name, then greet them with it:
print("What is your name?")
name = input()
print("Hello, " + name + "!")What is your name? Hello, Alex!
The program stopped at input() until the player typed Alex, then used that answer in the greeting.
You can ask more than once. Each input() waits for its own answer, and you save each one in its own variable to use later:
print("What is your name?")
name = input()
print("What is your favorite color?")
color = input()
print(name + " likes " + color + ".")What is your name? What is your favorite color? Alex likes blue.
Two questions, two answers, saved in name and color. That back-and-forth is how a program has a real conversation.
Now in a text adventure. The player picks a direction — we print the question, call input() to wait, and save whatever they type in choice:
print("You reach a fork. Which way? Type north or south.")
choice = input()
print("You chose:", choice)You reach a fork. Which way? Type north or south. You chose: north
The program paused at input() until the player typed north, then carried on using it. That's how a program has a real back-and-forth with a person.
input() is how programs ask people things: your name in a game, a number in a quiz, a yes-or-no answer. Anywhere a program needs you to decide, it waits for your input.
Try it yourself
Add a first question: print "What is your name?", then name = input(), and greet them with print("Hello,", name). Now your program knows who's playing.
The common mistake
Forgetting that input() always gives back text. If you ask for a number and type 5, you get the text "5", not the number 5. To do math with it, turn it into a number first with int(...).
What it unlocks
Reading input pairs with print output, and lets while loops keep asking until the answer makes sense.