Reputation: 43
class animal:
def __init__(self,name,tag):
self.name = name
self.tag = tag
def build(self):
return f"{self.name} is a {self.tag}"
class insect(animal):
pass
animal1 = animal("Cow","4 legs,2 horns")
insect1 = insect("Spyder","8legs, small sized")
animal1.build()
insect1.build()
after implementing this script I am not getting any output please check it. but instead of return if given print function the output is shown
Upvotes: 0
Views: 58
Reputation: 1164
Because your class used return, not print:
print(animal1.build())
print(insect1.build())
Output:
Cow is a 4 legs,2 horns
Spyder is a 8legs, small sized
Upvotes: 1