Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #814

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
class Person:
# write your code here
pass
people = {}

def __init__(self, name: str, age: int) -> None:
self.name = name
self.age = age
Person.people[name] = self

def create_person_list(people: list) -> list:
# write your code here
pass

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

for person_data, person_instance in zip(people, person_instances):
wife_name = person_data.get("wife")
husband_name = person_data.get("husband")

if wife_name and wife_name is not None:
person_instance.wife = Person.people.get(wife_name)
if person_instance.wife:
person_instance.wife.husband = person_instance

if husband_name and husband_name is not None:
person_instance.husband = Person.people.get(husband_name)
if person_instance.husband:
person_instance.husband.wife = person_instance

return person_instances
Loading