name = input("What is your name? ")Line-by-line explanation
inputdisplays a question and waits.- The text inside brackets is the question.
- The user types an answer and presses Enter.
namestores that answer as a string.
input() always returns a string, even if the person types digits.
age_text = input("Age: ")Line-by-line explanation
- The prompt
Age:appears. - The user types an answer.
age_textstores text such as"12".
Tiny Practice
Ask the user for a favorite food and store the answer.
Starter template
food = CHANGE_ME
print(food)Line-by-line explanation
- The first line must ask a question.
- The second line displays the answer.
Hint
- Use
input. - Put the question inside quotes.
- Keep the result in
food.
Show Solution
food = input("Favorite food: ")
print(food)Line-by-line explanation
inputasks and waits.- The answer is stored in
food. printdisplays it.