Mad Libs Game
Made libs is a game where you create a story by filling in blanks with words.
Let's try making this game in Python.
How it works
- First, we will make a template for the story with few blanks
- Next, we will fill in the blank with user input (
input()
) - Lastly, we will print that entire sentence
Making the game in Python
- Make a template
- Let's set "Roses are ?. Violets are ?. And I like ?." as the template
{}
is the placeholder for the blanks
sentence = "Roses are {}. Violets are {}. And I like {}."
- Ask the user for the values of the blanks
- We will use
input()
to get the user's input (fw
,sw
, andtw
)
- We will use
fw = input("Adjective : ")
sw = input("Adjective 2 : ")
tw = input("Person's name: ")
- Fill in the blanks in the template
- Using the
format()
method will replace all the blanks with the user's input
- Using the
finish = sentence.format(fw, sw, tw)
- Printing
- We will print the finished story
print(finish)