Madlibs Incomplete Story


#1

Hi, I'm getting stuck with the first Madlibs project. I don't get any error message. However, the words that I tried filling in the blanks don't show up in the story on the terminal. Here's the code:

"""
This program does
the following...

Author: Lynn
"""

name = raw_input("Jace:")
first_adj = raw_input("salty")
second_adj = raw_input("sweaty")
third_adj = raw_input("greasy")

first_verb = raw_input("sneeze")
second_verb = raw_input("jump")
third_verb = raw_input("flick") 

first_noun = raw_input("Dumbbells")
second_noun = raw_input("Birds")
third_noun = raw_input("Gin")
fourth_noun = raw_input("Chiili")



animal = raw_input("a cow")
food = raw_input ("Tom Yum")
fruit = raw_input("a Banana")
number = raw_input("9998899")
superhero = raw_input("Wonderwoman")
country = raw_input("Nicaragua")
dessert = raw_input("cheese cake")
year = raw_input("14,000 BC")






#The template for the story
STORY = "This morning I woke up and felt %s because %s was going to finally %s over the big %s %s. On the other side of the %s were many %s protesting to keep %s in stores. The crowd began to %s to the rythym of the %s, which made all of the %s very %s. %s tried to %s into the sewers and found %s rats. Needing help, %s quickly called %s. %s appeared and saved %s by flying to %s and dropping %s into a puddle of %s. %s then fell asleep and woke up in the year %s, in a world where %s ruled the world."

print STORY % (first_adj, name , first_verb , second_adj , first_noun , second_noun , animal , food , second_verb , third_noun , fruit , third_adj , name , third_verb , number, name , superhero , superhero , name , country , name , dessert , name , year , fourth_noun)

Thank you,
Lynn


#2

raw_input() is used to get something from the user. The words between the quotes are meant to be a prompt to the user: raw_input("Name?"). Then the story will use whatever you type after each prompt at runtime.

You could remove all instances of raw_input() and just leave the strings coded in:

name = "Jace"
first_adj = "salty"
second_adj = "sweaty"
third_adj = "greasy"

Or you can provide prompts for the user and proceed to type in answers when you run it:

name = raw_input("Name:")
first_adj = raw_input("Adjective:")
second_adj = raw_input("Adjective:")
third_adj = raw_input("Adjective:")

Both ways will work. The second way is more like the real Mad Libs works since you make a new story every time you run it.


#3

It worked. Thank you!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.