Python - Mad Libs Project.Error message


#1



I've been stuck at this all day. Can't figure out what the problem is. I followed the instruction along with the exercise.
Not sure what the issue is with my code. Any help is appreciated. Thank you.


When I run it, this is what I get:

Enter a name:John
Enter an adjectiveHappy
provide another adjectivebig
prodivde one more adjectivefunny
Enter a verbjump
enter a second verbrun
one more verbhit
Enter a nounLand
Enter a 2nd nounPhone
enter a 3rd nounbook
one more nounball
give the name of an animalbunny
give the name of a foodpear
give the name of a fruitapple
enter any number10
provide the name of a superherobatman
name a countryEngland
name a type of dessert pudding
enter a year2020
Traceback (most recent call last):
File "Madlibs.py", line 43, in
print STORY % (first_adj, name, first_verb, sec
ond_adj, first_noun, second_noun, animal, food, sec
ond_verb, third_noun, fruit, third_adj, name, third
_verb, number, name, superhero, superhero, name, co
untry, name, dessert, name, year, fourth_noun)
ValueError: unsupported format character 't' (0x74)
at index 187


""" This program is similar to mad libs. You will read the story and then when prompted, fill in the blank with a word of your choosing. WHen finished, the completed story will be provided for you """



print "Mad Libs is running!" 

name = raw_input ("Enter a name:")

first_adj = raw_input ("Enter an adjective")
second_adj = raw_input ("provide another adjective")
third_adj = raw_input ("prodivde one more adjective")

first_verb = raw_input ("Enter a verb")
second_verb = raw_input ("enter a second verb")
third_verb = raw_input ("one more verb")

first_noun = raw_input ("Enter a noun")
second_noun = raw_input ("Enter a 2nd noun")
third_noun = raw_input ("enter a 3rd noun")
fourth_noun = raw_input ("one more noun")

animal = raw_input ("give the name of an animal")
food = raw_input ("give the name of a food")
fruit = raw_input ("give the name of a fruit")
number = raw_input ("enter any number")
superhero = raw_input ("provide the name of a superhero")
country = raw_input ("name a country")
dessert = raw_input ("name a type of 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 % 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 % (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)

.


#2

There is your culprit.


#3

Thank you. Boy I feel a dunce. I was stuck on this one most of the day. Appreciated. Reminds me of that time in Excel where I spent 4 hours on a syntax error I couldn't see that was staring me in the nose.


#4

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