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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1706

wants to merge 1 commit into from

Conversation

workhardpolly
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on implementing the Person class and the create_person_list function! 🎉 Your code meets the core requirements of the task and functions as expected. There are a couple of minor improvements you could consider for future projects: using the dict.get() method can help simplify your code and prevent potential KeyError exceptions, and list comprehensions can make your code more concise. Keep up the good work and happy coding! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

# write your code here
pass
person_list = []
for person in people:

Choose a reason for hiding this comment

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

Consider using list comprehension instead of a traditional for loop when creating a list of instances from a collection, as recommended by the checklist .

for person in people:
person_proto = Person(person["name"], person["age"])

if "wife" in person and person["wife"] is not None:

Choose a reason for hiding this comment

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

Use the dict.get() method instead of explicitly checking for the presence of a key to simplify the code and avoid potential KeyError exceptions .

person_proto.wife = Person.people.get(
person["wife"], Person(person["wife"], 0))
person_proto.wife.husband = person_proto
elif "husband" in person and person["husband"] is not None:

Choose a reason for hiding this comment

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

Use the dict.get() method instead of explicitly checking for the presence of a key to simplify the code and avoid potential KeyError exceptions .

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.

2 participants