Madlibs Error


#1



Every time I run the Mad Libs, I get this error after entering all the adjectives/verbs/nouns/etc.:

Traceback (most recent call last):
File "Madlibs.py", line 33, in <module>
print STORY % (adj1, name, vrb1, adj2, noun1, noun2, anml, food, vrb2, noun3, fruit, adj3, name, vrb3, nmbr, name, sprhro, sprhro, name, cntry, name, dsrt, year, noun4)
TypeError: not enough arguments for format string

Here is my code:

print "Mad Libs has begun!! >:)"

name = raw_input("Enter a name: ")

adj1 = raw_input("Enter an adjective: ")
adj2 = raw_input("Enter a second adjective: ")
adj3 = raw_input("Enter a third adjective: ")

vrb1 = raw_input("Enter a verb: ")
vrb2 = raw_input("Enter a second verb: ")
vrb3 = raw_input("Enter a third verb: ")

noun1 = raw_input("Enter a noun: ")
noun2 = raw_input("Enter a second noun: ")
noun3 = raw_input("Enter a third noun: ")
noun4 = raw_input("Enter a fourth noun: ")

anml = raw_input("Enter an animal: ")
food = raw_input("Enter a food: ")
fruit = raw_input("Enter a fruit: ")
nmbr = raw_input("Enter a number: ")
sprhro = raw_input("Enter a superhero: ")
cntry = raw_input("Enter a country: ")
dsrt = raw_input("Enter a dessert: ")
year = raw_input("Enter a year: ")

#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 %ss protesting to keep %s in stores. The crowd began to %s to the rythym of the %s, which made all of the %ss 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 %ss ruled the world."

print STORY % (adj1, name, vrb1, adj2, noun1, noun2, anml, food, vrb2, noun3, fruit, adj3, name, vrb3, nmbr, name, sprhro, sprhro, name, cntry, name, dsrt, year, noun4)


#2

You have 25 instances of %s and only 24 items to use in their place.


#3

Do you know what variable I didn't use?


#4

You used all of them at least once, it appears. You just have one too many %s markers. Remove one and it should work.


#5

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