diff --git a/app/main.py b/app/main.py index f6bcaa1dd..ca0905682 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,29 @@ 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) -> list: + + person_instances = [] + for person_data in people_list: + name = person_data.get("name") + age = person_data.get("age") + person = Person(name, age) + person_instances.append(person) + + for person_data in people_list: + name = person_data.get("name") + current_person = Person.people[name] + + if "wife" in person_data and person_data["wife"]: + current_person.wife = Person.people[person_data["wife"]] + if "husband" in person_data and person_data["husband"]: + current_person.husband = Person.people[person_data["husband"]] + + return person_instances