18/18 please explain to me, why it doesn't works?


#1

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


#2

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.


#3

i'm not sure why i'm still lost in this solution, but how did angle suddenly become "self".angle?


#4

Also don't just put in:

def init(self)

you should put in:

def __init__(self)

hope it works!


#5

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.


#7

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


#8

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.


#9

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...)


#10

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!)


#11

int must be init


#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


#13

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


#14

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?


#15

never mind, i need angle arguments because i'm redefining the init function.