Class it Up


#1


https://www.codecademy.com/courses/python-intermediate-en-WL8e4/3/2?curriculum_id=4f89dab3d788890003000096#

Oops, try again. It looks like your Triangle class doesn't have a number_of_sides member variable.


Replace this line with your code. 

class Triangle(object):
    def __init__(self,angle1,angle2,angle3):
        self.angle1=angle1
        self.angle2=angle2
        self.angle3=angle3
        self.number_of_sides=3  
    def check_angles(self):
        if self.angle1+self.angle2+self.angle3==180:
            return True
        else:
            return False


#2

i think i have to initiate it that way
number_of_sides=Triangle(3) but still same error


#3

Your class should have that attribute, not the instances themselves (the instances will fall back to the class's attributes, so setting the attribute on the class means that all instances will fall back to it, meaning that they'll all share the same value)

Triangle(3) returns a Triangle object (assuming that it doesn't crash, which it will, because you need more arguments for your definition of __init__ which currently wants three arguments, excluding the instance itself)
and setting number_of_sides to a Triangle object is quite something else from what's asked for


#5

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