class Cat:
species = 'mammal'
def __init__(self, name, age):
self.name = name
self.age = age
cat1 = Cat('Billy', 2)
cat2 = Cat('John', 3)
cat3 = Cat('Kuro', 1)
print(cat1.name, cat1.age)
print(cat2.name, cat2.age)
print(cat3.name, cat3.age)
def oldest_age(*args):
return max(args)
print(f'The oldest cat is {oldest_age(cat1.age, cat2.age, cat3.age)} years old.')
After doing all this, I get the following output which contains just the maximum age, but I want to also get the corresponding name of the cat which is the oldest. How do i put is oldest-age function inside the class? Billy 2 John 3 Kuro 1 The oldest cat is 3 years old.
WHAT I WANT AS OUTPUT Billy 2 John 3 Kuro 1 The oldest cat is John which is 3 years old.