Skip to content

madlibs #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 43 additions & 22 deletions Madlibs/madlibs.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
import random
print("Title : Eat, Drink, And Be Sick")
noun = []
for i in range(4):
n = input("Enter noun : ")
noun.append(n)
plural = []
for i in range(6):
pn = input("Enter plural noun : ")
plural.append(pn)
adjective = []
for i in range(2):
a = input("Enter adjective : ")
adjective.append(a)
adverb = input("Enter adverb : ")
letter = input("Enter any letter : ")
body_part = input("Enter any body part : ")
print("An inspector from the Department of Health and ", random.choice(noun) , " Services paid a surprise visit to our " , random.choice(adjective) , " school cafeteria.")
print("The lunch special, prepared by our " , random.choice(adjective) , "dietician, was spaghetti and " , random.choice(noun) , " balls with a choice of either a " , random.choice(noun) , " salad or French " , random.choice(plural) , ".")
print("The inspector found the meat-" , random.choice(plural) , " to be overcooked and discovered a live " , random.choice(noun) , " in the fries,causing him to have a " + body_part + " ache.")
print("In response, he threw up all over his " , random.choice(plural) , ".")
print("In his report, the inspector " + adverb + " recommended that the school cafeteria serve only nutritious " , random.choice(plural) , " as well as low-calorie " , random.choice(plural) , " and that all of the saturated " , random.choice(plural) , " be eliminated.")
print("He rated the cafeteria a " + letter + "-minus.")
from sys import exit

def get_user_input(prompt):
while True:
user_input = input(prompt)
if user_input:
return user_input.strip()
else:
print("Please enter a valid input.")

def play_madlib():
print("Title: Eat, Drink, And Be Sick")
nouns = [get_user_input("Enter noun: ") for _ in range(4)]
plural_nouns = [get_user_input("Enter plural noun: ") for _ in range(6)]
adjectives = [get_user_input("Enter adjective: ") for _ in range(2)]
adverb = get_user_input("Enter adverb: ")
letter = get_user_input("Enter any letter: ")
body_part = get_user_input("Enter any body part: ")

print("\nAn inspector from the Department of Health and", random.choice(nouns), "Services paid a surprise visit to our", random.choice(adjectives), "school cafeteria.")
print("The lunch special, prepared by our", random.choice(adjectives), "dietician, was spaghetti and", random.choice(nouns), "balls with a choice of either a", random.choice(nouns), "salad or French", random.choice(plural_nouns), ".")
print("The inspector found the meat-", random.choice(plural_nouns), "to be overcooked and discovered a live", random.choice(nouns), "in the fries, causing him to have a " + body_part + " ache.")
print("In response, he threw up all over his", random.choice(plural_nouns), ".")
print("In his report, the inspector", adverb, "recommended that the school cafeteria serve only nutritious", random.choice(plural_nouns), "as well as low-calorie", random.choice(plural_nouns), "and that all of the saturated", random.choice(plural_nouns), "be eliminated.")
print("He rated the cafeteria a " + letter + "-minus.")

return get_user_input('\nDo you want to play again? (Yes/No): ').lower().startswith('y')

def main():
print("Starting the madlib game...\n")
play_again = True
while play_again:
play_again = play_madlib()

print("You've chosen not to play.")
print('Exiting....')
exit(0)

if __name__ == '__main__':
main()



13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My GitHub Pages Example</title>
</head>
<body>
<h1>Welcome to My GitHub Pages Example</h1>
<p>This is a simple HTML file to demonstrate GitHub Pages.</p>
<p>You can add more content, styles, and scripts as needed for your project.</p>
</body>
</html>