Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Nicholas Anstis
2,095 PointsPython print (if) == to something
So here's my problem. I want the program to print out the Monster if the monster is 'Creeper' but for some reasons it doesn't work
My code is down in the link.
My file is Personal_game.py (https://w.trhou.se/p2expqaant)
2 Answers
jorritcarton
6,206 PointsWhen you use a function to draw/print your creeper, you should call the name of the function. You did write the function, but did not call it. Now it only prints the enemy you are fighting.
Cindy Lea
Courses Plus Student 6,497 PointsI believe you need parenthesis around your conditon:
Your code:
if enemy == 'creeper':
should be if (enemy == 'creeper')
Nicholas Anstis
2,095 PointsNicholas Anstis
2,095 PointsThanks I understand but where should I put the run of the function. I tried to put it like that :
https://w.trhou.se/l0vy0fpx5d
but now i get a name error.
jorritcarton
6,206 Pointsjorritcarton
6,206 PointsYou tried to call your function when it was not specified yet. Just copy/paste your function after 'import random' on line 2 and it should work fine!
Nicholas Anstis
2,095 PointsNicholas Anstis
2,095 PointsThanks a lot it works :D!