Instantiate an Object


Hey I'm not exactly certain what's wrong here, I'm assuming I've made some small error that I'm currently overlooking. I keep getting "Oops, try again. Did you create an instance of Triangle called my_triangle?"

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
    my_triangle = Triangle(60, 90, 30)
    print my_triangle.number_of_sides
    print my_triangle.check_angles()


Hey thomispurdy!

It looks like the last three lines of your code have been tabbed so that they are considered inside the class Triangle. Try getting rid of the tab and running it again.


It works now! Thank you! Can't believe I didn't notice that.


No Problem, Glad to help!


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