From 1ecc316f7ec4193b29b1793fff69c7da2d4d56dd Mon Sep 17 00:00:00 2001 From: Darya-Savchenko Date: Sat, 14 Dec 2024 03:27:27 +0200 Subject: [PATCH] solution --- app/main.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index f6bcaa1dd..3b250e22e 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,23 @@ 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 + +def create_person_list(people: list) -> None: + person_list = [] + for person in people: + person_instance = Person(name=person["name"], age=person["age"]) + person_list.append(person_instance) + + for person in people: + person_instance = Person.people[person["name"]] + if "wife" in person and person["wife"] is not None: + person_instance.wife = Person.people[person["wife"]] + elif "husband" in person and person["husband"] is not None: + person_instance.husband = Person.people[person["husband"]] + + return person_list