Skip to content

Commit

Permalink
used list comprehension and updated the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
RangerLeoo committed Nov 19, 2023
1 parent 3848a39 commit 4b59323
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def __str__(self) -> str:


def create_person_list(people: list) -> list:
person_list = []
person_list = [
Person(name=person["name"], age=person["age"])
for person in people
]

for index, person in enumerate(people):
person_list.append(Person(name=person["name"], age=person["age"]))

for index, person in enumerate(people):
if "wife" in person and person["wife"] is not None:
if person.get("wife"):
person_list[index].wife = Person.people[person["wife"]]
elif "husband" in person and person["husband"] is not None:
elif person.get("husband"):
person_list[index].husband = Person.people[person["husband"]]

return person_list

0 comments on commit 4b59323

Please sign in to comment.