# 17, I receive message that my triangle takes no parameters

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

Perhaps you misnamed the `__init__` method, the `__init__` inherited from `object` doesnâ€™t take any arguments.

BTW, take care to get the formatting right when you post code, if you copy the code in your post into the editor and run it, youâ€™ll notice that youâ€™ll get different errors.

1 Like
``````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()
``````

canâ€™t tell without formatting but my guess is that you had indented the bottom three lines when you should not have

3 Likes

That is more simple:
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.number_of_sides == 3:
return True
elif self.number_of_sides == 180:
return False
else:
return 0
my_triangle = Triangle(90, 30, 60)
print my_triangle.number_of_sides
print my_triangle.check_angles()

I donâ€™t know why but the instructions are wrong. It wants you to put in:

``````print my_triangle.check_angles()
``````

Do that, WRONG.
Erase that, and

``````print my_triangle.number_of_sides
``````

should be the last line.
If you do that, it gives you a green.

2 Likes

I thought so initially as well but then there is something wrong with your code I had:

``````def check_angles(self,angle1,angle2,angle3):
if sum(angle1 + angle2 +angle3)==180:
return True
else:
return False
``````

but it should of been slightly different all though the above gave me a pass. I changed the sum part and also the arguments this caused my code to get an error if I donâ€™t say

``````print my_triangle.check_angles()
``````
``````  def check_angles(self):
if self.angle1 + self.angle2 + self.angle3 ==180:
return True
else:
return False
``````

so the whole block of code that prints correct values and gets a pass is like suggested is:

``````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()
``````
1 Like

thanks @scriptmaster â€¦it helps me to clear this outâ€¦

Same code returns 3 & True but still gives â€śOops, try again. Did you create an instance of Triangle called my_triangle?â€ť errorâ€¦ This is frustrating!

have even tried changing the sequence of angles in the printâ€¦check_angle(a1,a2,a3)statement

got it â€¦indentation of the print statements!

I have copied and pasted the exact same code and it is still giving me an error.

@tyriverag: Like it was commented in earlier posts, make sure you instanciate the object outside itâ€™s class scope, otherwise the compiler will go crazy about it.
In other words, pay attention to indentation.

If it still doesnâ€™t work, post the code so we can take a look!

The init function seems to be named wrong (itâ€™s supposed to be `__init__`)
Hereâ€™s my code that works:

``````class Triangle(object):
number_of_sides = 3
def __init__(self, angle1, angle2, angle3):
self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3
def check_angle(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_angle()
``````

just check the init function, as that uses parameters
By the way, this comment is meant the very top post

I had number_of_sides == 3 and it took forever to pass this exercise

Why doesnâ€™t this work? The editor is â– â– â– â– â– â– â–  â– â– â– â– â– â– â– â–  My indentation is fine I just cant post it

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,60,30)
print my_triangle.number_of_sides
print my_triangle.check_angles()