0
In addition to b class 2 has a c parameter, is this the correct way to code?
class 1: def __init__(self, a, b): self.a = a self.b = b class 2(1): def__init__(self, b, c): super().__init__(b, b) self.c = c
3 Respostas
+ 2
class names can't start with a number. Other than that everything seems fine to me.
+ 1
Sandeep i tried to instantiate it but it failed:
class x:
def __init__(self, a, b):
self.a = a
self.b = b
class y(x):
def__init__(self, b, c):
super().__init__(b, b)
self.c = c
S = y(1, 4)
print(S.c)
+ 1
Lenoname there is a typo in class y, __init__ constructor
add a space after 'def' keyword