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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Solution #778

wants to merge 4 commits into from

Conversation

Shatrovskyi
Copy link

No description provided.

@Shatrovskyi
Copy link
Author

To be honest, I think my implementation of the task is not good. Can someone help to implement this task in a more convenient way?

@Shatrovskyi
Copy link
Author

Now It may be better)

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

Choose a reason for hiding this comment

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

Suggested change
Person.people[name] = self
self.pople[name] = self

maybe it will be better

app/main.py Outdated
for index, person in enumerate(people_data):
wife = person.get("wife")
husband = person.get("husband")
if wife is not None:
Copy link

Choose a reason for hiding this comment

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

Is not None is redundant here, since in your case if statement will be True if key exists

Copy link
Author

Choose a reason for hiding this comment

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

Got it!

app/main.py Outdated
husband = person.get("husband")
if wife is not None:
person_list[index].wife = Person.people.get(wife)
if husband is not None:
Copy link

Choose a reason for hiding this comment

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

same

app/main.py Outdated
def create_person_list(people_data: dict) -> list[Person]:
person_list = []

for person_item in people_data:
Copy link

Choose a reason for hiding this comment

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

Try to rewrite in one line. Hint: list comprehension 🤫

Copy link

@fsocie7y fsocie7y left a comment

Choose a reason for hiding this comment

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

GJ 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants