Time to practice using lists and strings! We’ll use them with the random library to create random sentences.

Remember your parts of speech? Nouns, verbs, adjectives, adverbs, and so on… Start by coming up with a sentence structure, like this:

My [type of relative], a(n) [adjective] [occupation], likes to [verb] [adverb].

Next, you’ll want to create lists with several of each of the parts of speech (or other Mad Libs categories) you used in your sentence structure.

relatives = ['aunt', 'great-grandfather', 'cousin', 'long-lost half-sister']
adjectives = ['green', 'tall', 'talented', 'shiny', 'confusing']
nouns = ['accountant', 'trapeze artist', 'florist', 'crane driver']
verbs = ['cartwheel', 'jog', 'bake', 'code', 'yodel']
adverbs = ['quickly', 'daily', 'upside-down', 'at night']

Import the random library at the top of your program. When you’re only using one function from a library, you can take a shortcut: from random import randrange.

Now, you can call randrange without naming its library. Use randrange to get a random index for each “blank” in the sentence.

rel = randrange(len(relatives))
n = randrange(len(nouns))
etc.

Last, use concatenation to put it all together!

print('My ' + rel + ', a(n) ' + adj + occ + ', likes to ' + vb + '.')

Every time you run your program, you’ll get a different sentence. Add more words to your lists to make your sentences seem even more random!