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 trialKristin Sellers
5,457 PointsGetting a NameError when trying this in workspace
Here's my code:
class monster():
def __init__(self, hit_points, weapon, color, sound):
self.hit_point = hit_points
self.weapon = weapon
self.color = color
self.sound = sound
def battlecry(self):
return self.sound.upper()
When I try and use the shell to follow along, I get a message saying: File "<stdin>", line 1, in <module> NameError: name 'Monster' is not defined
Does anyone know what I've done wrong?
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi Kristin,
The class name should be Monster with a capital 'M' in the code.
If you're still getting errors then copy and paste what your console looks like.
Kristin Sellers
5,457 PointsThank you for catching that! It's working now.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 Pointsfixed code formatting