Instantiate an Object - object.__new__() takes no parameters


#1

Please help

Traceback (most recent call last):
File "python", line 14, in
TypeError: object.new() takes no parameters

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

my_triangle = Triangle(90, 45, 45)
print my_triangle.number_of_sides
print my_triangle.check_angles()


#2

Hi, @yarik2001 ,

The name of the __init__ method should be corrected to begin and end with two underscores, respectively, here ...

def init(self,angle1,angle2,angle3):

#3

Oh.Thank you)
I didn't notice


#4

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