← All missions

πŸ“– Silly Story Generator

πŸ† Final Showcase Projects

1) What do I need to do?

🎯 Your mission: Your silly story

Ask for at least 5 words with input().

Print a story of at least 3 lines that uses every word.

Bonus: use a loop to let them play again!

2) What do I need to know?

How Mad Libs works

Ask the player for random words β€” a noun, a verb, an adjective, a number β€” without telling them the story.

Then put the words into a story with f-strings. The result is usually hilarious!

A noun is a thing (banana). A verb is an action (dance). An adjective describes something (sparkly).

🧰 Your toolkit for this mission

Everything you need to know to finish this lesson on your own:

Collect words

Ask for each word with input() and store it.

How to write it: One variable per word.

noun = input("A noun: ")
verb = input("A verb: ")

Build the story

Join your text and the words.

How to write it: Commas in print add spaces; + glues with no space. Or use an f-string: f"The {noun} likes to {verb}".

print("The", noun, "loves to", verb + "!")
print(f"The {noun} loves to {verb}!")

Think about it

Look at this code. What happens next, and why? Say it in your own words.

print(f"The {colour} {animal} danced!")
Watch & explore β–Ά

Power-up: How Mad Libs works

See it happen

1 / 3
animal = input("An animal? ")
animal
dragon

Ask for a word. A noun names something, like a dragon.

3) Run the code & terminal output

Code Lab 🐍Playground β€” experiment freely!
Hero Terminal

Press β–Ά RUN and your program's messages appear here!

Cosmic Studio
Cosmic Studio
Your superhero companion

Captain Py

Our next adventure is yours to create.