When I run this Python program, dog.bark()
returns "This dog is barking" but dog.eat()
returns "This animal is eating".
I need dog.eat()
to also return "This dog is eating" using a variable similarly to this:
class Animal(Organism):
def eat(self):
print("This ***{self}*** is eating")
This would allow other animals to also return their own name instead of "animal". E.g "This turtle is eating, this squirrel is eating, etc.
Obviously {self}
is not the right syntax, that's why I'm looking for answers or resources regarding what I'm trying to do. If you could reply or redirect me that would be super nice.
class Organism:
alive = True
class Animal(Organism):
def eat(self):
print("This animal is eating")
class Dog(Animal):
def bark(self):
print("This dog is barking")
dog = Dog()
dog.eat()
dog.bark()