Skip to content

Commit

Permalink
Solutin_py_person_class
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladkrit11 committed Sep 12, 2023
1 parent e075ff6 commit eefa5e4
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
class Person:
# write your code here
pass
people = {}

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


def create_person_list(people: list) -> list:
# write your code here
pass
result = [Person(person["name"], person["age"]) for person in people]

for person in people:
human = Person.people[person["name"]]
if "husband" in person and person["husband"]:
husband_to_add = Person.people[person["husband"]]
setattr(human, "husband", husband_to_add)

elif "wife" in person and person["wife"]:
wife_to_add = Person.people[person["wife"]]
setattr(human, "wife", wife_to_add)

return result

0 comments on commit eefa5e4

Please sign in to comment.