Project: Mad Libs
Project: Mad Libs
- In this project you build a small story machine.
- It asks for a few words, then puts them into a story.
- You use what you know:
input(), joining strings with+, and string methods.
What you will build
Mia
cat
pizza
The story of Mia
================
Mia has a pet CAT.
It eats pizza every day.
- The first three lines are what the user types. The rest is the story.

Step 1: collect the words
- Each
input()reads one line. Store each word in its own variable. - Join the words with
+, and put the spaces inside the quotes.
Step 2: change a word
.upper()gives a CAPITAL copy:"cat".upper()is"CAT".- Each
printadds one line to the story.
Step 3: a title with a line under it
len(text)counts the characters in a string."=" * 5repeats a string five times:=====.- So
"=" * len(title)draws a line exactly as long as the title.
title = "Hello"
print(title)
print("=" * len(title))
Now build it
- Three steps. Each task starts with your code from the step before.
- Press Run and type the words yourself, then press Check answer.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
Step 1: read a nome, then an animal, each with input(). Print one sentence. For the inputs Mia e cat, print Mia has a pet cat.
Clique em Executar para ver a saída aqui.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
Step 2: also read a alimentos. Print two lines: the first sentence with the animal in CAPITALS, then It eats + the food + every day. A favor Mia, cat e pizza: Mia has a pet CAT. e It eats pizza every day.
Clique em Executar para ver a saída aqui.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
Step 3: start the story with a title, The story of + the name, and underline it with = signs exactly as long as the title (use len). For Mia the first two lines are The story of Mia e ================.
Clique em Executar para ver a saída aqui.