UPDATE: Many of the comments stated that my code required proper indentation. In my actual Python, I believe my indentation is correct. I just did not know how to properly indent it so that it would appear as code in this post!
Before you down vote or disregard this, please help! I'm not very skilled at Python and I have looked through some of the posts that are related to my question.
For a school project, I am required to create three Mad Libs stories and make sure that they are selected at random. I simply do not understand how to make these stories random! I've tried using the import random and the random.choice and things like that but it just does not work! Also, while I was experimenting with this, my Mad Libs will now not run as I would like it to!
Any assistance will be appreciated!
print("Welcome to my terrible Mad Libs stories. It is not a smart idea to run through my stories. In fact, it is much more wise for you to do something else.")
def story1 ():
proper_name = input("Why are you doing this. Enter a name: ")
adjective1 = input("Seriously. Stop. Enter an adjective: ")
adjective2 = input("Enter an adjective: ")
adjective3 = input("Enter an adjective: ")
adjective4 = input("ADJECTIVES. Enter an adjective: ")
adjective5 = input("Enter an adjective: ")
adjective6 = input("Why are there so many adjectives... Enter an adjective: ")
city = input("Enter a city name: ")
color = input("Enter a color: ")
plural_clothing = input("Enter a plural article of clothing: ")
plural_noun1 = input("Enter a plural noun: ")
plural_noun2 = input("Last one! Enter a plural noun: ")
plural_noun3 = input("HAH JUST KIDDING. Last one. Enter a plural noun: ")
plural_noun4 = input("AHAHAHA THAT WASN'T THE LAST ONE...Enter a plural noun: ")
print("{} has announced that his {} clothing "
"store in the heart of downtown {}, is having a {} "
"sale of all merchandise, including {} suits "
"and slightly irregular {}. Men's cable-knit "
"{}, only $15.99. Hand-woven Italian {}, half-price. "
"Double-breasted cashmere {}, $50.00. Genuine imported "
" {} {} shoes, {} handkerchiefs, "
"and women's embroidered {}, all at rock-bottom prices. "
"This is a chance to get some really {} bargains!".format(
proper_name, adjective1, city, adjective2, adjective3, plural_clothing, plural_noun1, plural_noun2, plural_noun3, color, adjective4, adjective5, plural_noun4, adjective6))
def story2 ():
proper_name = input("Enter a name: ")
disease = input("Enter a disease: ")
body_part = input("Enter a bodypart: ")
exclamation = input("Enter an exclamation: ")
adjective = input("Enter an adjective: ")
nasty_adjective = input("Enter a nasty adjective: ")
noun = input("Enter a noun: ")
plural_noun1 = input("You're still here? You should quit... enter a plural noun: ")
plural_noun2 = input("Enter another plural noun: ")
plural_noun3 = input("Almost done... enter another plural noun: ")
plural_noun4 = input("One more! Enter another plural noun: ")
print("Medical science and people, but mainly science, have discovered "
"that smoking cigarettes causes {} (obviously). It is also "
"bad for your {} and causes pains in the {} "
"(bet you didn't know that). When mice and cats were exposed to "
"{} cigarette smoke, they developed {} disease (gasp!). "
"Tobacco companies have put charcoal {} on the ends of cigarettes, "
"but they still spend millions of {} advertising their {} "
"product (gross). If you smoke cigarettes, the tobacco will leave all "
"kinds of tar and {} in your lungs. This will make you cough "
"and say, '{}!' Don't smoke cigarettes. Remember, only {} smoke.".format(
disease, noun, body_part, adjective, proper_name, plural_noun1, plural_noun2, nasty_adjective, plural_noun3, exclamation, plural_noun4))
def story3():
country = input("I love Mad Libs. Enter a geographic location: ")
adjective1 = input("The line before this one was false. Enter an adjective: ")
adjective2 = input("Enter an adjective: ")
clothing = input("Enter an article of clothing: ")
number1 = input("Enter a number: ")
number2 = input("Well, I guess you should enter another number: ")
plural_noun1 = input("How about a plural noun?: ")
plural_noun2 = input("Wait, you need another plural noun: ")
print("Here is tomorrow's weather report for AMERICA "
"and vicinity. Early tomorrow, a HAPPY front will "
"collide with a mass of hot PANTS moving from the "
"north. This means we can expect NICE winds and "
"occasional BIRDS by late afternoon. Wind velocity will "
"be 23 miles an hour, and the high temperature should "
"be around 12 degrees. So, if you're going out, you had "
"better plan on wearing your SHIRT. ".format(
country, adjective1, plural_noun1, adjective2, plural_noun2, number1, number2, clothing))
print((story1), (story2), (story3))
import random
define story(story1, story2, story3)
print(random.choice(story))
Aucun commentaire:
Enregistrer un commentaire