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!

stage 3 hack_n_slash

Make a new Warrior method called rage that sets attack_limit to 20.

warrior.py
from character import Character

class Warrior(Character):
  weapon = "sword"
  pass


from character import Character

class Warrior(Character):
  weapon = "sword"  

class some_class:
   a_value = 20
    #define a class method
    def some_method(self):
      return self.a_value 

2 Answers

Chase Marchione
Chase Marchione
155,055 Points

Hi there,

  • You do have part of the right idea! Looks like you're defining another class, though. Thankfully, all you need to do in Task 3 is define a new method and set a property within it.
  • The challenge wants you to use the names that it asks you to use (rage for the method, and attack_limit for the property you will be setting.)
  • Since you're setting a value, there is no need to return anything. Returning values is a concept for when we want to 'get' a value, but here we want to set the value of a property instead.

Example code:

from character import Character

class Warrior(Character):
  weapon = "sword"
  pass

  def rage(self):
    self.attack_limit = 20

Hope this helps!

Jose Luis Lopez
Jose Luis Lopez
19,179 Points

from character import Character

class Warrior(Character): weapon = 'sword' attack_limit = 20

def rage(self): return Warrior