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!

David Bouchare
David Bouchare
9,224 Points

String conversion, Warrior, class and instances

Hi everyone,

I am running into an issue when using the values from the instance of the Warrior class.

Here is the code that I wrote:

from character import Character

class Warrior(Character)
#weapon = 'sword'

  def rage(self, weapon, attack_limit):
    self.attack_limit = attack_limit
    self.weapon = weapon
    return "Warrior, {0}, {1}" .format(self.weapon, self.attack_limit)

"Looks like task 1 is no longer passing" is the error. I am sure I have done something wrong in the values attribution, but not sure exactly what.

Thanks in advance for the help.

David

3 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Task 1 requires you to set the weapon to 'sword', which you've commented out. So, yeah, Task 1 isn't passing any more.

As for the rage method, it doesn't get weapon or attack_limit arguments, so your function won't pass with those being required.

And the string should be done in the __str__ method, not the rage method.

David Bouchare
David Bouchare
9,224 Points

Ah yes thanks for pointing this out, I was really not fully awake when I wrote this code. Let me rewrite that today. Thanks for the help!

David Bouchare
David Bouchare
9,224 Points

Solved:

uncommented the weapon attribute and created the relevant str method. Thanks!