I know that self
is a reference of the class instance, but why could the instance refer to the attribute that has not been declared in the class? I mean, I think it should add three statements a = 0 b = 0 c = 0
in class Triangle
but it does't. Also in the next function print_side
.
class Triangle:
def create_triangle(self, a, b, c):
self.a = a
self.b = b
self.c = c
print("The triangle is created")
def print_side(self):
print('side a is: ', self.a)
print('side b is: ', self.b)
print('side c is: ', self.c)