I'm trying to achieve polymorphism in python via abstraction. Here's my code:
class Animal:
def talk(self):
print('Hello')
class Dog(Animal):
def talk(self):
print('Bark')
class Cat(Animal):
def talk(self):
print('meow')
myObj = Dog()
print(myObj.talk())
this achieves the purpose except when I create an object and print, I get the following output:
Bark
None
I was expecting to get just Bark. Can anyone explain to me why None is also printed?
myObj.talk()