From 2e16f41ddf4cbd3c4085d6646eb62f2dc228cf9f Mon Sep 17 00:00:00 2001 From: bc2024-4 Date: Sat, 21 Dec 2024 17:35:13 +0200 Subject: [PATCH] add files --- app/main.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index f6bcaa1dd..6b4f2f87b 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,25 @@ class Person: - # write your code here - pass + people = {} + + def __init__(self, name: str, age: int) -> None: + self.name = name + self.age = age + Person.people[name] = self def create_person_list(people: list) -> list: - # write your code here - pass + persons = [] + for person_data in people: + name = person_data["name"] + age = person_data["age"] + person = Person(name, age) + persons.append(person) + + for person_data in people: + person = Person.people[person_data["name"]] + if "wife" in person_data and person_data["wife"]: + setattr(person, "wife", Person.people[person_data["wife"]]) + if "husband" in person_data and person_data["husband"]: + setattr(person, "husband", Person.people[person_data["husband"]]) + + return persons