# 18/18 Inheritance

Oops, try again. Failed to instantiate Equilateral, an error was thrown: ‘Equilateral’ object has no attribute ‘angle1’

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

def __init__(self,angle1,angle2,angle3):
self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3
class Equilateral(Triangle):
angle = 60
def __init__(self):
self.angle = self.angle1
self.angle = self.angle2
self.angle = self.angle3
"Self.angle needs to be flipped."
self.angle1 = self.angle
self.angle2 = self.angle
self.angle3 = self.angle
"This is correct ^^"
my_triangle = Triangle(60,60,60)
print my_triangle.number_of_sides
print my_triangle.check_angles()

``````
what am i doing wrong here?

Aaaaaaannnddd I solved the problem myself…

Please try to post the solution so others who make the same mistakes can correct the issue.
Thanks.

``````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 sum([self.angle1,self.angle2,self.angle3])==180:
return True
return False

class Equilateral(Triangle):
angle = 60
def __init__(self):
self.angle1=self.angle2=self.angle3=self.angle

my_triangle = Equilateral()
print my_triangle.number_of_sides
print my_triangle.check_angles()``````
2 Likes

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