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 1 commit
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
36 changes: 31 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
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 = []

for person_data in people:
name = person_data["name"]
age = person_data["age"]

person = Person(name, age)
AnyoneClown marked this conversation as resolved.
Show resolved Hide resolved

wife_name = person_data.get("wife")
husband_name = person_data.get("husband")

if wife_name is not None:
person.wife = Person.people.get(wife_name)
if person.wife:
person.wife.husband = person # Set the husband for the wife

if husband_name is not None:
person.husband = Person.people.get(husband_name)
if person.husband:
person.husband.wife = person # Set the wife for the husband

person_instances.append(person)

return person_instances
Loading