Skip to content

Commit

Permalink
simplified condition by using method.get()
Browse files Browse the repository at this point in the history
  • Loading branch information
IvankaKuzin committed Dec 4, 2024
1 parent e2b87bd commit 218f81f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ def create_person_list(people: list) -> list:
for person in people
]
for person in people:
person_object = Person.people[person["name"]]
if "wife" in person:
if person["wife"]:
wife = Person.people[person["wife"]]
person_object.wife = wife
elif "husband" in person:
if person["husband"]:
husband = Person.people[person["husband"]]
person_object.husband = husband
person_object = Person.people[person.get("name")]
if person.get("wife"):
wife = Person.people[person.get("wife")]
person_object.wife = wife
elif person.get("husband"):
husband = Person.people[person.get("husband")]
person_object.husband = husband
return person_objects

0 comments on commit 218f81f

Please sign in to comment.