Welcome to the Mad Libs Generator page.
This page contains a brief description and implementation instructions for the project.
Project Description
A word game generator. The program offers one or more story templates with blanks (e.g. "noun", "adjective"). The user inputs random words to fill in each blank, and the program then prints the complete story. This is a fun way to practice string formatting and user input.
Project Requirements
Python 3.x (no libraries needed; optional tkinter
if building a GUI).
How to Run the Project
- Write a script (e.g.
madlibs.py
) that contains story templates (strings with placeholders). - Run it:
python madlibs.py
. It may display available stories, then ask the user to enter words for each blank (e.g. “enter an adjective:”). - After input, print the completed story with the words inserted.
Key Concepts Learned
- String Handling: Concatenation or formatting (
f-strings
) to insert user-provided words into a template. - User Input: Asking the user for different parts of speech (noun, verb, etc.).
- Lists: Optionally storing multiple templates and selecting one.
- Control Flow: Using loops or functions to manage the flow of prompts and story creation.
Possible Extensions
- Add more story templates.
- Implement random story selection for surprise.
- Use a GUI with dropdowns or text fields instead of console.
- Add input validation (e.g. ensure noun/verb fields are filled).