From 70f4cc83704a177bdfaba52727b691cbefc8cd78 Mon Sep 17 00:00:00 2001 From: Dmytro Karaniaga Date: Mon, 23 Oct 2023 15:13:25 +0300 Subject: [PATCH] Fixed mentor comments --- app/main.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/main.py b/app/main.py index d022f2f08..f2a3bf20d 100644 --- a/app/main.py +++ b/app/main.py @@ -8,15 +8,21 @@ def __init__(self, name: str, age: int) -> None: def create_person_list(people: list) -> list: - for person in people: - if person["name"] not in Person.people: - Person(person["name"], person["age"]) + person_list = [ + Person.people[person["name"]] + if person["name"] in Person.people + else Person(person["name"], person["age"]) + for person in people + ] for person in people: - if "wife" in person and person["wife"] is not None: - Person.people[person["name"]].wife = Person.people[person["wife"]] - elif "husband" in person and person["husband"] is not None: - Person.people[person["name"]].husband \ - = Person.people[person["husband"]] + if person.get("wife"): + Person.people[person["name"]].wife = ( + Person.people.get(person["wife"]) + ) + elif person.get("husband"): + Person.people[person["name"]].husband = ( + Person.people.get(person["husband"]) + ) - return list(Person.people.values()) + return person_list