class Animal:
def init(self):
self.age = 1
def eating(self):
print(“eat”)
class Mammal(Animal):
def walking(self):
print(“walk”)
class Fish(Animal):
def swimming(self):
print(“swim”)
m = Mammal
m.eating()
print(m.age)
class Animal:
def init(self):
self.age = 1
def eating(self):
print(“eat”)
class Mammal(Animal):
def walking(self):
print(“walk”)
class Fish(Animal):
def swimming(self):
print(“swim”)
m = Mammal
m.eating()
print(m.age)
Hi! First of all you have to use init (with double underscores on each side) and not init.
Secondly when you create an instance of your class you should use m = Mammal() with “()”.
Full code:
class Animal:
def __init__(self):
self.age = 1
def eating(self):
print("eat")
class Mammal(Animal):
def walking(self):
print("walk")
class Fish(Animal):
def swimming(self):
print("swim")
m = Mammal()
print(m.age)
m.eating()
Hope it helps