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 trialLiana Moleni
2,644 Pointswhen warrior is converted to a string
i cannot seem to notice where im going wrong.
from character import Character
class Warrior(Character):
pass
weapon = 'sword'
def rage(self):
self.attack_limit = 20
def __str__(self):
return "{} {}, weapon {},attack_limit {}".format(self.__class__,
self.weapon,
self.attack_limit)
4 Answers
Jeremy Fisk
7,768 PointsI think they actually want the string "Warrior" instead of the {} {} at the beginning of your return statement...
Jeremy Fisk
7,768 PointsAdditionally, they do not want the strings "weapon" and "attack limit" included in your return statement ....
Annie Scott
27,613 Pointsfrom character import Character class Warrior(Character): weapon = 'sword'
def rage(self): self.attack_limit = 20
def str(self):
string = "{}, {}, {}".format(Warrior.name, self.weapon, self.attack_limit)
return string
Dan Johnson
40,533 PointsThe __class__
attribute deals with the class type. You were probably looking for the __name__
attribute:
"{}, {}, {}".format(Warrior.__name__, self.weapon, self.attack_limit)
You can also drop the pass
since you have a class definition.
Liana Moleni
2,644 PointsLiana Moleni
2,644 Pointsits not working Jeremy