Skip to content

Commit

Permalink
Task Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Arty-tech-dotcom committed Dec 4, 2024
1 parent fb72ddb commit 04909fc
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ class Person:
def __init__(self, name: str, age: int) -> None:
self.name = name
self.age = age
Person.people[name] = self
Person.people[self.name] = self


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

for person in person_list:
for person_dict in people:
if person_dict["name"] == person.name:
if "wife" in person_dict:
if person_dict["wife"] is not None:
person.wife = Person.people[person_dict["wife"]]
if "husband" in person_dict:
if person_dict["husband"] is not None:
person.husband = Person.people[person_dict["husband"]]
return person_list
for person in people:
pers = Person(person["name"], person["age"])
result.append(pers)

for person in people:
current_person = Person.people[person["name"]]
if person.get("wife"):
current_person.wife = Person.people[person["wife"]]
if person.get("husband"):
current_person.husband = Person.people[person["husband"]]
return result

0 comments on commit 04909fc

Please sign in to comment.