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

Python Object-Oriented Python (retired) Hack-n-Slash Warriors! Come Out and Play-ay!

I need help !

Treehouse is telling me that task number 1 is no longer passing but i'm doing everything right please someone help me.

warrior.py
from character import Character
class Warrior(Character):

    weapon = 'sword'
    self.weapon = weapon

    def rage(self):
        attack_limit = 20
        self.attack_limit = attack_limit

    def __str__(self):
        return "Warrior, {}, {}".format(self.weapon, self.attack_limit)

3 Answers

I agree with Ryan that challenges can be quite particular about formatting and spelling, I did find that this passed without the <>

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) 
Ryan S
Ryan S
27,276 Points

Hey John, good call. You are right, it will pass without the angle brackets.

I think the issue was actually defining self.weapon = weapon in the class which wasn't allowing the challenge to pass. I must've added the angle brackets and removed that one line in the same edit and saw that it passed. I didn't troubleshoot them one at a time.

Thanks for clearing that up.

Ryan S
Ryan S
27,276 Points

Hi Nicolas,

You have to be very mindful of how the challenge wants you to format your strings. You are missing the angle brackets <> around the weapon and attack_limit in your returned string.

And there are a couple redundancies in your code that can be removed.

from character import Character
class Warrior(Character):

    weapon = 'sword'    #  You don't need to define self.weapon

    def rage(self):
        self.attack_limit = 20    # You can set self.attack_limit directly, without an intermediary variable

    def __str__(self):
        return "Warrior, <{}>, <{}>".format(self.weapon, self.attack_limit)

Thanks both of you :) !!!