16. Class It Up


#1

I'm having trouble with this exercise. Any suggestions? I'm getting the following error message:

Oops, try again. It looks like your Triangle class doesn't have a number_of_sides member variable.

Here is my code:

class Triangle(object):
def init(self, angle1, angle2, angle3):
self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3
number_of_sides = 3
def check_angles(self):
if self.angle1+self.angle2+self.angle3==180:
return True
else:
return False


#2

Have you tried: self.number_of_sides = 3?
Or, you can move the number_of_sides = 3 before your __init__ and after class Triangle.

class Triangle(object):
    number_of_sides = 3
    def init(self, angle1, angle2, angle3):
    #Rest of your code

#3

this is a great website but how do i see if i understand the material


#4

The only way to learn code, is to keep practicing. If the exercises start making sense to you, and you are able to produce code, you are starting to understand the materials.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.