WHen I execute, it throws the error:
....
......
class Dog(Pet):
File "D:\untitled2\Pet.py", line 13, in Dog
Dog.numberoflegs = 4
NameError: name 'Dog' is not defined
Fish.numberoflegs = 0
NameError: name 'Fish' is not defined
please help
class Pet:
numberoflegs = 0
def sleep(self,name):
print("the {} sleeps".format(name))
def countlegs(self):
print("I have {} legs".format(self.numberoflegs))
#type = input("enter pet type")
#dog.sleep(type)
class Dog(Pet):
Dog.numberoflegs = 4
def bark(self):
print ("the dog sounds woof")
class Fish(Pet):
Fish.numberoflegs = 0
kuta = Dog()
kuta.countlegs()
kuta.bark()
machi = Fish()
machi.countlegs()