Share your repls and programming experiences

← Back to all posts
Mad Libs
EvanTkatch (5)

A Mad Libs program created by DrQuackels Evan Tkat steakyfish45 and driftnut. Asks for words and creates a funny story.

Commentshotnewtop
Muffinlavania (684)

Cool mad libs! Could I suggest something? If you wanted, you could make it randomly choose a format for the nouns and stuff.
you could import random at the top,
then have something like this:
rand_num=random.randint(1,whatever)
if rand_num==1:
print("One day, " + myName + " was going on a " + noun1 + ". It was " + day + ". They came upon a " + adj1 + " " + noun2 + ". It was on a " + noun3 +". " + myName + " " + adverb + " " + verb + " the " + noun2 + ". It was very " + adj2 + "!")
if randnum==2:
other printing option here
and so on

Driftnut (4)

Thanks! Thats actually a great idea. @Muffinlavania

Muffinlavania (684)

@Driftnut 👍 and also a kind of not so helpful thing, but it works is f strings
Instead of this:
print("One day, " + myName + " was going on a " + noun1 + ". It was " + day + ". They came upon a " + adj1 + " " + noun2 + ". It was on a " + noun3 +". " + myName + " " + adverb + " " + verb + " the " + noun2 + ". It was very " + adj2 + "! ")
You can do this:
print(f"One day, {myName} was going on a {noun1}. It was {day} . They came upon a {adj1} {noun2}. It was on a {noun3}.{myName} {adverb} {verb} the {noun2}. It was very {adj2} !")
Basically it is the same things but very simple, before the sting put an f, then whenever you want a variable put { then your variable } in the string!
So like print("Hello {name]") would take name as a variable

studentAlfredAl (390)

Nice job! Keep it up :)