I'm trying to create a madlib program that writes the story by selecting a random item from each list. I'm required to use a main function and a function that chooses items from the lists and then displays the story.
def main():
person=["John","Patrick","Kenny","Susan","Brittany"]
place=["Miami","Los Angeles","New York","Seattle","Tuscon"]
adjective=["hot","cold","windy","warm","cool"]
noun=["dog","cat","skateboard","game","bike"]
plural_noun=["dogs","cats","skateboards","bikes","tables"]
food=["pizza","fries","grapes","watermelon","chicken"]
verb=["eat","run","walk","jump","sit",]
return person,place,adjective,noun,plural_noun,food,verb
display()
def display():
import random
name=random.choice(person)
pl=random.choice(place)
adj=random.choice(adjective)
nouns=random.choice(noun)
pnoun=random.choice(plural_noun)
f=random.choice(food)
v=random.choice(verb)
print("Last summer,we went for a vacation with",name,"on a trip to",pl,". The weather there is
very",adj,"! Northern",pl,"has many",pnoun,"and they make",pnoun,"there.")
print()
print("Many people there also go to the",pl,"to",v,". The people who live there like to eat",f,".
They also like to",v,"in the sun and swim in the",nouns,".")
print("It was a really",adj,"trip!")
main()
~~~
Aucun commentaire:
Enregistrer un commentaire