16. Clas It Up


I passed the exercise but have a question. below is the code that passed but when I change the additions to angle1 + angle2 + angle3 ==180, it no longer works. Why is that so?

In the first method I am setting self.anglex= anglex so I was expecting angle1 + angle2 + angle3 ==180 to pass just same as self.angle1 + self.angle2 + self.angle3==180

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
            return False


Only the __init__ method sees the raw parameters. check_angles sees only the instance variables.


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