anonymous
  • anonymous
Pls help def generateForm(story, listOfAdjs, listOfNouns, listOfVerbs): """ story: a string containing sentences listOfAdjs: a list of valid adjectives listOfNouns: a list of valid nouns listOfVerbs: a list of valid verbs For each word in story that is in one of the lists, * replace it with the string '[ADJ]' if the word is in listOfAdjs * replace it with the string '[VERB]' if the word is in listOfVerbs * replace it with the string '[NOUN]' if the word is in listOfNouns returns: string, A Mad-Libs form of the story. """
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
Its python
anonymous
  • anonymous
THE CODE def generateForm(story, listOfAdjs, listOfNouns, listOfVerbs): """ story: a string containing sentences listOfAdjs: a list of valid adjectives listOfNouns: a list of valid nouns listOfVerbs: a list of valid verbs For each word in story that is in one of the lists, * replace it with the string '[ADJ]' if the word is in listOfAdjs * replace it with the string '[VERB]' if the word is in listOfVerbs * replace it with the string '[NOUN]' if the word is in listOfNouns returns: string, A Mad-Libs form of the story. """ s = story.split() #splits on whitespace only for i in range(len(s)): if s[i] in listOfAdjs: s[i] = '[ADJ]' elif s[i] in listOfNouns: s[i] = '[NOUN]' elif s[i] in listOfVerbs: s[i] = '[VERB]' return ' '.join(s) THE TEST listOfAdjs = ['adj1', 'adj2', 'adj3'] listOfNouns = ['noun1', 'noun2', 'noun3'] listOfVerbs = ['verb1', 'verb2', 'verb3'] story = "Once upon a noun1 verb2 adj3 I had a noun2 verb3 adj1 and then noun3" mad = generateForm(story, listOfAdjs, listOfNouns, listOfVerbs) print(mad) THE OUTPUT Once upon a [NOUN] [VERB] [ADJ] I had a [NOUN] [VERB] [ADJ] and then [NOUN]
anonymous
  • anonymous
Thank you @msmithhnova

Looking for something else?

Not the answer you are looking for? Search for more explanations.