โ† Back to Python Course
๐Ÿ Python Playgroundยท25 minยทBeginner๐Ÿ† Project
๐ŸŽ‰

Mini-Project: Mad Libs Generator

Create silly stories with code!

Use everything you learned โ€” variables, strings, and print โ€” to build a Mad Libs story generator!

๐Ÿ“–

What we are learning

Time to build your first real project! A Mad Libs generator asks for words (like a noun, an adjective, and a verb), then plugs them into a story to create something hilarious. You will use variables to store the words and string concatenation to build the story.

๐Ÿ’ก Think of it like this:

Mad Libs is like a fill-in-the-blanks party game. You ask friends for random words without telling them the story. Then you read the story with their words plugged in โ€” and everyone laughs!

๐ŸŒŸ

Why it matters

This project combines everything you have learned so far: print, variables, strings, and input. It proves you can build something fun and real with just a few lines of code!

Where you see this in real life:

  • โœ“Story generators and text-based games
  • โœ“Form letters that personalize names and details
  • โœ“Chat bots that combine templates with user input
๐ŸŽฏ

By the end, you can:

  • 1.Combine variables and strings into a story
  • 2.Use input() to get words from the user
  • 3.Build a complete, runnable Python program
๐Ÿ”ค

New words

inputconcatenationtemplatevariable
๐Ÿ
Think of the funniest noun, adjective, and verb you can. Write them down โ€” you will use them in your program!
๐Ÿค“

Fun Fact!

Mad Libs was invented in 1953 and has sold over 150 million copies. Now you are building your own digital version!

๐ŸŽ‰ Build a Mad Libs Generator!

Time for your first real project! A Mad Libs generator asks for words (a noun, an adjective, a verb) and plugs them into a story to create something hilarious.

You will use input()to get words from the user, store them in variables, and join them into a story with +.

๐Ÿ“ The input() Function

input()asks the user a question and waits for them to type an answer. Whatever they type gets stored as a string!

๐ŸTry input()
main.py
โ— Output
Type your answer in the output area when prompted!

๐Ÿ—๏ธ Step 1: Collect Words

First, we ask the player for a bunch of words. We store each one in a variable.

๐ŸStep 1: Get words from the user
main.py
โ— Output
Click โ–ถ Run to see the output!

๐Ÿ—๏ธ Step 2: Build the Story

Now we plug the words into a story template using string concatenation (+).

๐ŸStep 2: The full Mad Libs!
main.py
โ— Output
Click โ–ถ Run to see the output!

๐Ÿš€ Challenge: Make It Your Own!

Now try writing your OWN Mad Libs story! Here are some ideas:

  • ๐ŸŒŸ Write a story about a day at school
  • ๐ŸŒŸ Write a story about a superhero adventure
  • ๐ŸŒŸ Write a story about a trip to outer space
  • ๐ŸŒŸ Add more words to make the story longer and sillier!
๐ŸYour turn!
main.py
โ— Output
Click โ–ถ Run to see the output!
๐Ÿ
Congratulations! You just built your first Python project! ๐ŸŽ‰ You used input, variables, and string concatenation all together!
๐Ÿง 

Quick Quiz!

+15 XP

What does the input() function do?

๐Ÿ
Finished the lesson? Click the button to mark it complete and earn XP!