I am currently learning how to program in Python I am stuck calling an attribute from a Parent class. In the example below, how can I call the attribute "name"
on "daisy" to print the name. I always get an error "'Mammal' object has no attribute 'name'
.
class Vertebrate:
spinal_cord = True
def __init__(self, name):
self.name = name
class Mammal(Vertebrate):
def __init__(self, name, animal_type):
self.animal_type = animal_type
self.temperature_regulation = True
daisy = Mammal('Daisy', 'dog')
print(daisy.name)
here I want to print the name which has been defined in the Vertebrate class, but I always get an error
"'Mammal' object has no attribute 'name'"