From 34a321353500d87150276e843aaee32358419caf Mon Sep 17 00:00:00 2001 From: Leo Date: Sat, 28 Dec 2024 16:21:06 +0200 Subject: [PATCH] done --- app/main.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index f6bcaa1dd..11bd21e8e 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,25 @@ class Person: - # write your code here - pass + people = {} -def create_person_list(people: list) -> list: - # write your code here - pass + 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[Person]: + new_people_list = [] + + for human in people: + new_people_list.append(Person(human["name"], human["age"])) + + for human in people: + if "wife" in human and human["wife"]: + Person.people[human["name"]].wife = Person.people[human["wife"]] + elif "husband" in human and human["husband"]: + Person.people[human["name"]].husband = ( + Person.people)[human["husband"]] + + return new_people_list