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
else:
return False
class Equilateral(Triangle):
angle = 60
def init (self):
self.angle = self.angle1
self.angle = self.angle2
self.angle = self.angle3
Your last 3 lines:
self.angle = self.angle1
self.angle = self.angle2
self.angle = self.angle3
should be
self.angle1 = self.angle
self.angle2 = self.angle
self.angle3 = self.angle
self.angle is already equal to 60, this is āself.angle1ā, āself.angle2ā and āself.angle3ā that you want to be equal to 60.
6 Likes
iām not sure why iām still lost in this solution, but how did angle suddenly become āselfā.angle?
Also donāt just put in:
def init(self)
you should put in:
def __init__(self)
hope it works!
I think this is because the:
def __init__(self):
self.angle1 = self.angle
self.angle2 = self.angle
self.angle3 = self.angle
Takes the argument of self. Also it says self.angle1 because you need to set the previous angle degrees to 60. Most of the previous lessons had
def __init__(self, #another argument here):
Whereas this just has one argument: self.
1 Like
hm⦠I have another one problem. My code is below:
class Triangle():
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()
class Equilateral(Triangle):
angle=60
def _init__(self):
self.angle1=self.angle
self.angle2=self.angle
self.angle3=self.angle
and it throws me an error:
Oops, try again. It looks like init is missing from Equilateral AND/OR Triangle
Please help
1 Like
I entered the same code and got the same error message.
But, unless I have overlooked something, the code that you and I have entered in response to this lesson complies with the instructions given and, whatever the error message we both get may say, init is not missing from Equilateral and/or Triangle.
I can only suppose that, despite following to the letter the instructions given, we have somehow done something that the Codecademy program does not like.
Sorry, this is not much use to you. But advertising the fact more than one person has had the same problem may prompt someone else to help.
1 Like
itāseems that you forget a ā_ā in the method definition of Equilateral.
You writed def init _ (self) in place of def --init-- (self)
(please replace ā by __ because i donāt know why when I write __ before init and after itās doesnāt appear in the messageā¦)
I have the same problem (I wrote init correctly):
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
else:
False
my_triangle = Triangle(90,30,60)
print my_triangle.number_of_sides
print my_triangle.check_angles()
class Equilateral(Triangle):
angle = 60
def __int__(self):
self.angle1 = self.angle
self.angle2 = self.angle
self.angle3 = self.angle
Oops, try again. It looks like init is missing from Equilateral AND/OR Triangle. (Please help me and explain! thanks!)
chaxan
August 25, 2016, 6:53pm
#12
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()
class Equilateral(Triangle):
angle = 60
angle1=angle
angle2=angle
angle3=angle
def init (self):
pass
try creating three new variables for the class equilateral itāll work
the work is āwrite a new class equilateralā in of class write a function that check if the angles
passed are egual 60 whhy em um equilateral all angle are 60 use de if statement
I have
def init (self):
self.angle1 = self.angle
self.angle2 = self.angle
self.angle3 = self.angle
I get the error ādid you remember to create the angle attribute for equilateral?ā Why?
never mind, i need angle arguments because iām redefining the init function.