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 trialEvan Waterfield
3,240 Pointsstill getting an error even after making a new instance
class Monster:
hit_points = 1
color = 'yellow'
weapon = 'dead Badger'
sound = 'roar'
def battlecry(self):
return self.sound.upper()
>>> from monster import Monster
>>> jubjub = Monster
>>> jubjub.battlecry()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: battlecry() missing 1 required positional argument: 'self`
Evan Waterfield
3,240 PointsJones, what do insatiate my Monster class mean. I had the text they had in the video, his worked my didn't. I still don't understand. Bad time to quit smoking AHHHHHHHHHH
1 Answer
Jones Dias
13,902 PointsEvan, just do this jubjub = Monster() instead of jubjub = Monster
When you call a class this way Monster
you're not creating the object. That's why you're getting an error when you call the battlecry method.
Don't forget the () when creating an object and you're good to go ;)
Evan Waterfield
3,240 PointsSo now my question is that after putting the " () 's" it say its missing the 4 required part, which makes sense but in the video when Kenneth ran it jubjub = Monster() , then jubjub.battlecry() and he got the result of ROAR. Why'd he'd not have to fulfill the 4 positional arguments?
Jones Dias
13,902 PointsJones Dias
13,902 PointsEvan, seems like there's something really important missing on
jubjub = Monster
You forgot to insatiate the Monster class xD