17/18 help plz


#1

class Triangle(object):
number_of_sides = 3
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
my_triangle = Triangle(90,60,30)
print my_triangle.number_of_sides
print my_triangle.check_angles()
I get the error Oops, try again. Did you create an instance of Triangle called my_triangle?
when there clearly is


#2

Hi @nathaz1999 ,

Because your code is not formatted, it is difficult for other users to read and debug it. After code is been pasted into the editing window for posting, you can format it by selecting it, and then by clicking the </> button above the editing area. This will enable us to see important details, such as the indentation and underscores.

We cannot see your indentation. If you, by mistake, indented the following statements, they were part of the Triangle class definition, and did not get executed when you submitted your code ...

my_triangle = Triangle(90,60,30)
print my_triangle.number_of_sides
print my_triangle.check_angles()

#3

nathaz1999, this is my code:

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

My guess looking at yours (although I can't be sure), is that the instance my_triangle is indented when it should not be