Mad libs
Cass Okay, hi! I'm on crew entertainment duty for the next two weeks and I have absolutely nothing planned. Can you build a mad libs thing? Asks everyone for a few words, slots them into a story, prints the chaos. Doesn't have to be smart. Preferably isn't 😄
What you're building
Give me a noun: pizza
Give me a verb: exploded
Give me an adjective: sparkly
Give me a place: the library
The sparkly pizza exploded in the library. Nobody saw it coming.What you'll need
- Output and input — collecting each word from the player
- Strings — f-strings to slot the words into the story template
- Lists — one way to store the collected words before using them
- Functions — optional, but wrapping "ask for a word" in a function cleans things up
Hints
Collect first, then print. Gather all the words before you build the story. Mixing input() calls with story output gets confusing fast.
F-strings are the natural fit. Once you have all the words, a single f-string with the variables dropped in is all you need to build the output line.
Variables or a list. You can store each word in its own variable (noun = ..., verb = ...) or collect them all in a list. Either works — think about which is cleaner to read when you write the story line.
Going further
Once the basic version works:
- Multiple templates. Write two or three different story templates and pick one at random using the
randommodule. - More word types. Add plural nouns, past-tense verbs, numbers, or colours. The more blanks, the funnier the result.
- Let the player choose. Show the available story templates by name and let the player pick before collecting words.

