Continue to Execute Your Strategy
00:00 It seems like I have a functioning approach here. So there’s a couple of steps of just execution now because I need to do the same thing for verbs, adjectives, prepositions, and then adverbs.
00:10
So let’s do it for verbs. verbs = []
, and then for _ in range(3):
00:21
I want to pick out a verb by using random.choice()
.
00:28
Pick it out from the words
tuple at index position one, which is how I can access this list of verbs, and then I want to remove it. So I’ll say words[1].remove()
the value that I just picked out, and then append it to the verbs
, to the new verbs
list out here.
00:55
verbs.append(verb)
. I do that three times and then we can also print it out, print(verbs)
, and run the code to double check whether it’s working.
01:09 Okay, we get elephant, horse, and artwork, and then three verbs: hauls, hugs, and shimmers.
01:16 Cool. That’s working. It looks like you could just keep going like that to get all of the random selections of the different words that you need. But I want to play a little more with list methods, different approaches that you can solve this in the same way.
01:30 So for the adjectives, prepositions and the adverb, we’re going to use slightly different approaches to show you a variety of how you could potentially solve this task.
Become a Member to join the conversation.