class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def print_people(people):
for person in people.values():
print(f"Name: {person.name}, Age: {person.age}")
def find_old(people_dict):
if not people_dict:
print("The dictionary is empty.")
return
oldest_person = max(people_dict, key=lambda x: people_dict[x])
print(f"The oldest person is {oldest_person} with age {people_dict[oldest_person]}")
people_list = {
"kid1": Person("kid1", 1),
"kid2": Person("kid2", 2),
"kid3": Person("kid3", 3)
}
print_people(people_list)
people_dict = {"kid1": 1, "kid2": 2, "kid3": 3}
find_old(people_dict)
# Output is:
# Name: kid1, Age: 1
# Name: kid2, Age: 2
# Name: kid3, Age: 3
# The oldest person is kid3 with age 3
Name: kid1, Age: 1
Name: kid2, Age: 2
Name: kid3, Age: 3
The oldest person is kid3 with age 3