From da4b8dd7d1c2bcbe12882db2d6adf6558a3231ba Mon Sep 17 00:00:00 2001 From: Alex Moon Date: Mon, 23 Oct 2023 05:19:59 +0200 Subject: [PATCH] Done --- app/main.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index f6bcaa1dd..4fb46aa9d 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,22 @@ 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 + result_list = [] + for person_dict in people: + name = person_dict["name"] + Person(name, person_dict["age"]) + result_list.append(Person.people[name]) + for person_dict in people: + name = person_dict["name"] + if "wife" in person_dict and person_dict["wife"] is not None: + Person.people[name].wife = Person.people[person_dict["wife"]] + if "husband" in person_dict and person_dict["husband"] is not None: + Person.people[name].husband = Person.people[person_dict["husband"]] + return result_list