Hopefully you have tried a few mad-libs in your time. If you haven't, the idea is to fill in the blanks to a short story with the appropriate language parts (e.g. verb, noun, etc). When you are finished it is often a funny story. You will be implementing the part that randomly retrieves language parts for the main mad libs program.

 

Setup

Fork the following repository and clone your copy (if you haven't already for this lesson).

Mad Libs

Open languageparts.py in your text editor.

For this assignment you are not writing the main program but are writing a module that the main program will use. Run the program using:

python mad-libs.py

Requirements

Imports

  • use the random module to randomly select items from lists

Dictionaries and Lists

  • create a dictionary with at least the following language parts: noun, verb, adjective. Each language part will have a list of words that match that type. You may add more language parts but you must have the minimum set listed above.
  • make sure the given language part is in the dictionary before trying to get the parts.
  • randomly select an item from the list associated with the given language part.

results matching ""

    No results matching ""