Skip to content

Commit

Permalink
Class Person
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii-A committed Nov 11, 2023
1 parent e075ff6 commit c7bf35c
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
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 = []

for person_data in people:
name = person_data["name"]
person = Person.people.get(name)

if not person:
person = Person(name, person_data["age"])

if person_data.get("wife") is not None:
person.wife = Person.people.get(person_data["wife"])

elif person_data.get("husband") is not None:
person.husband = Person.people.get(person_data["husband"])

person_list.append(person)

return person_list

0 comments on commit c7bf35c

Please sign in to comment.