Simple Mad Libs generator game in Python
This is a type of game with some random names, prepositions, verbs, and adjectives in Python.
Mad Libs In Python:
Here is the code for mad libs in Python:
import random print("Mad Libs") any_name=input('any_name: ') your_name=input('Your Name: ') place= input('Place: ') adj= input('Adjective:') adjectives= ["Crazy", "Nice", "Lovely", "Gross"] Verbs= ["met", "proposed to", "robbed", "pushed"] Prepositions= ["above the", "near the", "around the", "behind", "beside"] print((random.choice(adjectives)) + " " + random_name + " " + (random.choice(Verbs)) + " " + your_name + " " + (random.choice(Prepositions))+ " " + adjective + " " + place )
Output: Mad Libs any_name: Bharu Your_name: nagi Place: Macherla Adjective: lovely Crazy Bharu met nagi near the macherla
Explanation:
From the above code, we understood that we are using the random module for taking a random name from the user
And we got the final output as the above sentence “Crazy Bharu met nagi near the macherla”.
You can also learn: Build your first game with Arcade Library in Python
Leave a Reply