diff --git a/app/main.py b/app/main.py index f6bcaa1dd..4f61852cb 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 + self.wife = None + self.husband = None -def create_person_list(people: list) -> list: - # write your code here - pass + Person.people[name] = self + + +def create_person_list(people_list: list) -> list: + persons = [] + + for one in people_list: + name = one["name"] + age = one["age"] + person = Person(name, age) + persons.append(person) + + for one in people_list: + name = one["name"] + person = Person.people[name] + + if "wife" in one and one["wife"]: + person.wife = Person.people.get(one["wife"]) + elif "husband" in one and one["husband"]: + person.husband = Person.people.get(one["husband"]) + + return persons