Create Mad Libs game in Python
pythonscholar
Posted on October 20, 2021
What is Mad Libs Game?
Mad Libs is the quintessential game of make-believe. You provide a list of words, and everyone else adds in their own silly, outrageous, or even absurd ideas for what they might be. Everyone laughs uproariously while using the best words, puns, and turns of phrase they can think up. There are tons of variations that you can take your Mad Libs adventures with at any time to suit your mood or theme.
Mad Libs Generator will give you a variety of prompts that you can use to start your story, or you can use them as the basis for your own stories. You then get to add in your funny word-puns, slogans, quotes, poetry beats, and even sound effects.
You can check our How to Create Mad Libs game in Python guide to learn more about mad libs games using Python.
Now let's see a simple tutorial on how to create a mad libs game using only basic python skills; mostly, we will use python string and python input-output function.
Step 1: In the first step, we will take the required input from the user and store it in the python variable to use in the future in our mad lib story. Copy the below code in your python compiler or Python IDE.
verb_1 = input("Enter a verb of choice, and press enter:")
adj_1 = input("Enter a adjective of choice, and press enter:")
verb_2 = input("Enter second verb of choice, and press enter:")
body_part = input("Enter a body part name of choice, and press enter:")
adverb = input("Enter an adverb of choice, and press enter:")
body_part_2 = input("Enter any body name of your choice,and press enter:")
noun = input("Enter a noun of choice, and press enter:")
verb_3 = input("Enter the third verb of choice, and press enter:")
animal = input("Enter name of any animal of choice, and press enter:")
noub_2 = input("Enter an noun of choice , and press enter:")
verb_4 = input("Enter the fourth verb of choice, and press enter:")
adj_2 = input("Enter an adjective of choice, and press enter:")
color = input("Enter any color name, and press enter:")
Step 2: Now, let’s add the user inputs into a story and make it a fun game, here; we will use python string to print our story.
story = "Most doctors agree that bicycle of" + verb_1 + " is a/an " + adj_1 + " form of exercise." + 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 +". No 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! "
Step 3: In the last step, we will print the story to get the final output of our name.
print(story)
As you can see, just using basic python skills, we have created a small game.
We hope you have enjoyed this tutorial and learned something new.
Happy learning.
Posted on October 20, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.