The TypeError: not all arguments converted during string formatting


#1

Getting the error message in the title. At some glances, it seems that the number of %s in the template seems to be equal to the number in the print function. Making a mistake somwhere.


"""This little piece of code will prompt user for words which will be placed into a story template"""

print "Mad Libs is ready to roll"
name = raw_input("Please enter your name")
adj1 = raw_input("Enter an adjective")
adj2 = raw_input("Enter another one")
adj3 = raw_input("One more time")

vrb1 = raw_input("Enter a verb")
vrb2 = raw_input("Enter another one")
vrb3 = raw_input("One more time")

noun1 = raw_input("Now we will need nouns. Enter one")
noun2 = raw_input("Yup, another one")
noun3 = raw_input("A third one")
noun4 = raw_input("One more time")

animal = raw_input("We need an animal name")
food =  raw_input("Enter a food")
fruit = raw_input("Now a fruit")
number = raw_input ("Enter a number")
superh = raw_input("Name a superhero")
country = raw_input("Enter the name of a    country")
dessert = raw_input("The name of 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, animal, food, vrb2, noun3, fruit, adj3, name, vrb3, number, name, superh, superh, name, country, name, dessert, name, year, noun4)


#2

OOPS. Never mind found the $ sign on the last variable.


#3

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