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 #887

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
22 changes: 18 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
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
person_list = [Person(person["name"], person["age"])
for person in people]

for person in people:
person_instance = Person.people[person["name"]]
if person.get("wife"):
person_instance.wife = Person.people[person["wife"]]
elif person.get("husband"):
person_instance.husband = Person.people[person["husband"]]

return person_list
1 change: 1 addition & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def test_person_instance_attribute_wife_and_husband_doesnt_exists():
with open(path_to_main()) as file:
tree = ast.parse(file.read())

print(ast.dump(tree))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never change test files.

assert (
len(
tree.__dict__["body"][0]
Expand Down
Loading