From 061293a8e969d62e162bf91ed7e21dd49a5ef01f Mon Sep 17 00:00:00 2001 From: Janam Jonchhe Date: Sun, 15 Mar 2026 10:02:25 +1100 Subject: [PATCH 1/2] Madlibs this is the 1st code for the game --- Madlibs | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Madlibs diff --git a/Madlibs b/Madlibs new file mode 100644 index 0000000..86ad4b9 --- /dev/null +++ b/Madlibs @@ -0,0 +1,62 @@ +# Mad Libs Game in Python +# Run this file and follow the prompts in the terminal + +import random + +def get_words(prompts): + words = {} + for key, text in prompts.items(): + user_input = input(f"Enter {text}: ") + words[key] = user_input.strip() + return words + + +def play_round(): + # Define the blanks needed + prompts = { + "name": "a name", + "place": "a place", + "adjective1": "an adjective", + "adjective2": "another adjective", + "noun1": "a noun", + "noun2": "another noun", + "verb_past": "a verb (past tense)", + "verb_ing": "a verb ending with -ing", + "animal": "an animal", + "number": "a number" + } + + words = get_words(prompts) + + # Story templates + stories = [ + ( + f"One day, {words['name']} went to {words['place']} with a very {words['adjective1']} {words['animal']}. " + f"Suddenly, a {words['adjective2']} {words['noun1']} {words['verb_past']} past them while {words['verb_ing']}. " + f"Everyone dropped {words['number']} {words['noun2']} and ran away!" + ), + ( + f"At {words['place']}, {words['name']} found a {words['adjective1']} {words['noun1']}. " + f"They {words['verb_past']} it and started {words['verb_ing']}. " + f"A {words['adjective2']} {words['animal']} appeared and gave them {words['number']} {words['noun2']} as a reward." + ), + ] + + print("\n--- Your Mad Libs Story ---\n") + print(random.choice(stories)) + print("\n---------------------------\n") + + +def main(): + print("🎉 Welcome to the Mad Libs Game! 🎉") + + while True: + play_round() + again = input("Play again? (y/n): ").lower().strip() + if again != 'y': + print("Thanks for playing! 👋") + break + + +if __name__ == "__main__": + main() From fb385ec4a735d68ce41ae8bb8aed21f377c620cf Mon Sep 17 00:00:00 2001 From: Janam Jonchhe Date: Tue, 17 Mar 2026 15:42:04 +1100 Subject: [PATCH 2/2] Update Madlibs --- Madlibs | 1 - 1 file changed, 1 deletion(-) diff --git a/Madlibs b/Madlibs index 86ad4b9..1d73696 100644 --- a/Madlibs +++ b/Madlibs @@ -1,5 +1,4 @@ # Mad Libs Game in Python -# Run this file and follow the prompts in the terminal import random