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!
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
MUZ140057 Dumisani Nyamusa8,029 Points
stage 3 hack_n_slash
Make a new Warrior method called rage that sets attack_limit to 20.
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
Chase Marchione151,726 Points
- 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.
from character import Character class Warrior(Character): weapon = "sword" pass def rage(self): self.attack_limit = 20
Hope this helps!
Jose Luis Lopez19,179 Points
from character import Character
class Warrior(Character): weapon = 'sword' attack_limit = 20
def rage(self): return Warrior