Mad Libs Error Code - 'noun_3' not defined


#1



#This program lets you create a story by inputting random words!
print "Welcome to the Mad Libs story game!"
name = raw_input("Enter your name:")
if len(name) > 0:
  print "Thank you"
else:
  print "Please enter a name"
#This is where the command to enter adjectives is
adjective_1 = raw_input("Enter an adjective:")
if len(adjective_1) > 0:
  print "Thank you"
else:
  print "Please enter an adjective"
adjective_2 = raw_input("Enter another adjective:")
if len(adjective_2) > 0:
	print "Thank You"
else:
  print "Please enter an adjective"
adjective_3 = raw_input("Enter one more adjective:")
if len(adjective_3) > 0:
  print "Thank You"
else:
  print "Please enter an adjective"
#verb commands
verb_1 = raw_input("Enter a verb:")
if len(verb_1) > 0:
  print "Thank you"
else:
  print "Please enter a verb"
verb_2 = raw_input("Enter another verb:")
if len(verb_2) > 0:
	print "Thank You"
else:
  print "Please enter a verb"
verb_3 = raw_input("Enter one more verb:")
if len(verb_3) > 0:
  print "Thank You"
else:
  print "Please enter a verb"
#noun commands
noun_1 = raw_input("Enter a noun:")
if len(noun_1) > 0:
  print "Thank you"
else:
  print "Please enter a noun"
noun_2= raw_input("Enter another noun:")
if len(noun_2) > 0:
	print "Thank You"
else:
  print "Please enter a noun"
  noun_3= raw_input("Enter another noun:")
if len(noun_3)>0:
	print "Thank You"
else:
  print "Please enter a noun"
noun_4= raw_input("Enter one more noun:")
if len(noun_4) > 0:
  print "Thank You"
else:
  print "Please enter a noun"
#miscellaneous commands
#animal command
animal = raw_input("Enter an animal:")
if len(animal) > 0:
  print "Thank You"
else:
  print "Please enter an animal"
#food command
food = raw_input("Enter a food:")
if len(food) > 0:
  print "Thank You"
else:
  print "Please enter a food"
#fruit command
fruit = raw_input("Enter a fruit:")
if len(fruit) > 0:
  print "Thank You"
else:
  print "Please enter a fruit"
#number command
number = raw_input("Enter a number:")
if len(number) > 0:
  print "Thank You"
else:
  print "Please enter a number"
#superhero name command
superhero = raw_input("Enter the name of a superhero:")
if len(superhero) > 0:
  print "Thank You"
else:
  print "Please enter the name of a superhero"
#country command
country = raw_input("Enter the name of a country:")
if len(country) > 0:
  print "Thank You"
else:
  print "Please enter the name of a country"
#dessert command
dessert = raw_input("Enter a dessert:")
if len(dessert) > 0:
  print "Thank You"
else:
  print "Please enter a dessert"
#year command
year = raw_input("Enter a year:")
if len(year) > 0:
  print "Thank You"
else:
  print "Please 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 % (adjective_1, name, verb_1, adjective_2, noun_1, noun_2, animal, food, verb_2, noun_3, fruit, adjective_3, name, verb_3, number, name, superhero, superhero, name, country, name, dessert, name, year, noun_4)

#Here is the error code. What's the problem and how do I fix it?
Enter another noun:t                                                           
Thank You                                                                      
Traceback (most recent call last):                                             
  File "Madlibs.py", line 52, in <module>                                      
    if len(noun_3)>0:                                                           
NameError: name 'noun_3' is not defined                                         
$


#2

the indention on this line:

  noun_3= raw_input("Enter another noun:")

looks off, now noun_3 gets only defined if the length of noun_2 is not greater then zero


#3

Thanks a lot! That solved the problem.


#4