From 9aeb1618a3b419f10cbda3156fd7ddd703ee5901 Mon Sep 17 00:00:00 2001 From: nagafochfv Date: Tue, 10 Dec 2024 21:55:33 +0200 Subject: [PATCH] 'Solution' --- app/main.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index f6bcaa1dd..845f5286d 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 + +def create_person_list(peoples: list) -> list: + person_list = [] + for pers in peoples: + person = Person(pers["name"], pers["age"]) + person_list.append(person) + for pers in peoples: + person = Person.people[pers["name"]] + if "wife" in pers and pers["wife"] is not None: + setattr(person, "wife", Person.people.get(pers["wife"])) + if "husband" in pers and pers["husband"] is not None: + setattr(person, "husband", Person.people.get(pers["husband"])) + return person_list