Python Madlib project


#1

Good day,

I am currently stuck on the madlibs project. I have completed all the steps but when i run the program, it ends up saying “NameError”. What am i doing wrong?

Strings and Console Output


#2

animals is not defined, if we look at line 20 we see the reason (check spelling)


#3

Aside

If we look at the print statement, it will work in Python 2, but not in Python 3. Python 2 does not need parens around the STORY object, so they can be removed. If you wish to make the code compatible with Python 3, then wrap the entire expression in parens.

print (STORY % (argument list))

#4

if i don’t add them it gives me the same error as before except it wasn’t animals but STORY


#5

Apart from the spelling correction, as long as you have 18 arguments to match the placeholders in the STORY template, this will suffice…

print STORY % (your_argument_list)

#6

Thanks for the help because I was having the same issue. Question: let’s say that I wanted to play again and I wanted to enter different answers, how would I do that?


#7

Just run the code again…

python Madlibs.py

#8

Thanks for the help, mtf


#9

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