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
Jessica Barron
1,215 PointsPlease tell me what is wrong with this code.
I am on the object-oriented python course and I cannot see what is wrong with this code. I need fresh eyes.
import random
COLORS = ['yellow', 'red', 'blue', 'green']
class Monster: min_hit_points = 1 max_hit_points = 1 min_experience = 1 max_experience = 1 weapon = 'sword' sound = 'roar'
def init(self, **kwargs): self.hit_points = random.randint(self.min_hit_points, self.max_hit_points) self.experience = random.randint(self.min_experience, self.max_experience) self.color = random.choice(COLORS)
for key, value in kwargs.items():
setattr(self, key, vlaue)
def battlecry(self): return self.sound.upper()
class Goblin(Monster): max_hit_points = 3 max_experience = 2 sound = 'squeak'
I don't know how to make the format of the code up to standards in questions so just imagine.
1 Answer
markmneimneh
14,133 PointsHello
It is hard to read the code after it got pasted on this page, but I see a typo here:
for key, value in kwargs.items(): setattr(self, key, vlaue)
vlaue should be value <<<<<<<<<<<<<<<
if you still see a problem, please repaste the code within htlm tags
Jessica Barron
1,215 PointsJessica Barron
1,215 PointsThank you markmneimneh!