This program should print Rex 3. It stops with AttributeError instead.
class Pet:
def __init__(self, name):
self.name = name
class Dog(Pet):
def __init__(self, name, age):
self.age = age
d = Dog("Rex", 3)
print(d.name, d.age)
Which one change makes it print Rex 3?
Log in to join the discussion.
Loading…