From 980c2de5a8715eaa74c6f56514ae708950664203 Mon Sep 17 00:00:00 2001 From: Olena Tretiak Date: Wed, 4 Dec 2024 00:52:19 +0200 Subject: [PATCH] Solution --- app/main.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index f6bcaa1dd..220ce3a06 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,21 @@ class Person: - # write your code here - pass + people = {} + + def __init__(self, name: str, age: int) -> None: + self.name = name + self.age = age + Person.people[self.name] = self def create_person_list(people: list) -> list: - # write your code here - pass + for person in people: + Person(person["name"], person["age"]) + + for person in people: + select_person = Person.people[person["name"]] + if "wife" in person and person["wife"]: + select_person.wife = Person.people[person["wife"]] + elif "husband" in person and person["husband"]: + select_person.husband = Person.people[person["husband"]] + + return list(Person.people.values())