#1

I keep getting an error that says ,
"Oops, try again. Your code threw the following error when it tried to check Triangle: global name 'Triangle' is not defined"

for this

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

#2

try this

``````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``````

perhaps its the init

#3

That worked! Thank you!!

#4

So you don't need to pass angle1, angle2 and angle3 as arguments to the method?

#5

thanks..been playing around with this exercise, then finally i got the answer. I should put the variable outside the method...and the journey is still running..alhamdulillah...thanks @rydan

#6

My code was-

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

-and I also changed it to-

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

-but the `sum()` function didn't work. Is it because `self.angle1, self.angle2, self.angle3` and `self.angle1 + self.angle2 + self.angle3` aren't integers? By the way, your code worked @rydan!

#7

maybe u should import math first

#8

The built-in `sum()` command works by iterating through a list. You can't use it by just throwing it a bunch of variables. You have to add them all manually.

#9

I have a question, why must we use self.angle1 but not angle1 when they're technically the same thing?

#10

Angle1 is only passed into the initialising method