- 1
can any 1 can give an example of code using super()?
3 Answers
+ 1
class Mammal:
def __init__(self, mammalName):
print(mammalName, 'is a warm-blooded animal.')
class Dog(Mammal):
def __init__(self):
print('Dog has four legs.')
super().__init__('Dog')
d1 = Dog()
0
class A:
def method(self):
print("A method")
class B(A):
def another_method(self):
print("B method")
class C(B):
def third_method(self):
print("C method")
c = C()
c.method()
c.another_method()
c.third_method()
here A is super class