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 trialAdiv Abramson
6,919 PointsI got another "Task 1 is not passing" error message. That doesn't help me find out what I did wrong in this task.
I don't know what error I have made in my code. Can you advise? Thank you.
from character import Character
class Warrior(Character):
weapon = 'sword'
attack_limit = 0
def rage(self):
self.attack_limit = 20
def __str__(self):
print "Warrior, {}, {}".format(self.weapon, self.attack_limit)
3 Answers
Stone Preston
42,016 Pointsyou need to return the string, not print it:
from character import Character
class Warrior(Character):
weapon = 'sword'
def rage(self):
self.attack_limit = 20
def __str__(self):
return "Warrior, {}, {}".format(self.weapon, self.attack_limit)
Adiv Abramson
6,919 PointsThank you. I have to get clear in my mind that redefining str involves returning instead of printing a string. I made this error earlier. Hopefully I will remember next time. :-)
Kenneth Love
Treehouse Guest TeacherSorry about the "Task 1 no longer passing" messages. I literally cannot change them. :(