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 trialDimitar Tsvetkov
6,806 PointsObject_oriented Python Challenge. Task 4 of 4. Please help
I am keep getting this error: Bummer! Expected "Warrior, axe, 40", got "<main.Warrior object at 0x7fb57bd699b0>". According to the str video this should be the proper way to call it as a string. My knowledge eds up here. Please help!
from character import Character
class Warrior(Character):
weapon = "sword"
def rage(self):
self.attack_limit = 20
def __str__(self):
return "{}, {}, {}".format(self.__class__.__name__, self.weapon, self.attack_limit)
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsYou are only off by 4 spaces:
from character import Character
class Warrior(Character):
weapon = "sword"
def rage(self):
self.attack_limit = 20
def __str__(self): #<-- unindented by 2
return "{}, {}, {}".format(self.__class__.__name__, self.weapon, self.attack_limit) #<-- unindented by 2
Dimitar Tsvetkov
6,806 PointsDimitar Tsvetkov
6,806 PointsThank you! I always have problems with indentation.