Class it up


Your code caused the following error: 'Triangle' object has no attribute 'angle1'

I don't know what's wrong, it seems correct, please help.

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


Consider whether you should have set such an attribute.
If not, then you shouldn't read what you shouldn't have set, right?
If yes, then this would indicate that you didn't and would therefore need to do something about that.

Also, please return the result of the boolean expression instead of using an if-statement to return True/False which is kind of redundant when you already have that value from the expression (code style, somewhat opinionated)


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