From d8b2b54b7f283ed043ba254d3ddbeca2f781eeac Mon Sep 17 00:00:00 2001 From: Prorochenko Oleksandr Date: Thu, 21 Sep 2023 21:21:55 +0300 Subject: [PATCH] 'Solution' --- app/main.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index f6bcaa1dd..4f9745236 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,31 @@ 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 + person_list = [] + for person_data in people: + name = person_data["name"] + age = person_data["age"] + + person_list.append(Person(name, age)) + + for person_data in people: + name = person_data["name"] + person = Person.people[name] + + if "wife" in person_data and person_data["wife"]: + person.wife = Person.people[person_data["wife"]] + elif "husband" in person_data and person_data["husband"]: + person.husband = Person.people[person_data["husband"]] + + return person_list