With below code I am trying to find the oldest of the 3 cats. When I try to call the method 'cat_age' of class 'Cat' in the print statement it gives the below error:
NameError: name 'cat_age' is not defined
Below is the code:
class Cat:
def __init__(self, name, age):
self.name=name
self.age=age
def cat_age(self, *args):
return max(args)
cat1=Cat('Pinky', 10)
cat2=Cat('Tinky', 11)
cat3=Cat('Sinky', 13)
print(f'The oldest cat is {cat_age(cat1.age, cat2.age, cat3.age)} years old')
Please help me understand what is going on.