Skip to content

Commit

Permalink
Merge pull request #332 from asingh4451/abhijotMadlib
Browse files Browse the repository at this point in the history
Update main.py
  • Loading branch information
Mrinank-Bhowmick authored Sep 29, 2023
2 parents f9c156a + 1c8cb7e commit 83aed7c
Showing 1 changed file with 34 additions and 43 deletions.
77 changes: 34 additions & 43 deletions projects/Madlibs Generator/main.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
verb_1 = input("Enter a verb of choice then press enter :")
adj_1 = input("Enter an adjective of choice :")
verb_2 = input("Enter second verb of choice :")
body_part = input("Enter a body part name of choice :")
adverb = input("Enter an adverb of choice :")
body_part_2 = input("Enter any body name of your choice:")
noun = input("Enter a noun of choice :")
verb_3 = input("Enter the third verb of choice :")
animal = input("Enter name of any animal of choice :")
noun_2 = input("Enter an noun of choice :")
verb_4 = input("Enter the fourth verb of choice :")
adj_2 = input("Enter an adjective of chioce :")
color = input("Enter any color name :")
def generate_madlib(choice, adjective, noun, verb, adverb):
stories = {
1: f"Once upon a time, there was a {adjective} {noun} who loved to {verb} {adverb}.",
2: f"In a land far away, a {adjective} {noun} decided to {verb} {adverb} every day.",
3: f"{adjective.capitalize()} and {noun.capitalize()}, the perfect pair, went on a journey to {verb} {adverb}."
}

return stories.get(choice, "Invalid choice!")

story = (
"Most doctors agree that bicycle of"
+ verb_1
+ " is a/an "
+ adj_1
+ " form of exercise.\n"
+ verb_2
+ " a bicycle enables you to develop your "
+ body_part
+ " muscles as well as "
+ adverb
+ " increase the rate of a "
+ body_part_2
+ " beat. More "
+ noun
+ " around the world "
+ verb_3
+ " bicycles than drive "
+ animal
+ ".\nNo matter what kind of "
+ noun_2
+ "you "
+ verb_4
+ " always be sure to wear a/an "
+ adj_2
+ " helmet.Make sure to have "
+ color
+ " reflectors too! "
)
def main():
print("Welcome to Mad Libs!")

# Choose a Mad Lib template
print("Choose a Mad Lib story:")
print("1. Once upon a time")
print("2. In a land far away")
print("3. A perfect pair")

choice = int(input("Enter the number of your choice (1-3): "))

if choice not in [1, 2, 3]:
print("Invalid choice. Please select a valid option.")
return

adjective = input("Enter an adjective: ")
noun = input("Enter a noun: ")
verb = input("Enter a verb: ")
adverb = input("Enter an adverb: ")

madlib = generate_madlib(choice, adjective, noun, verb, adverb)

print("Your Mad Lib Story:")
print(madlib)

print(story)
if __name__ == "__main__":
main()

0 comments on commit 83aed7c

Please sign in to comment.