-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: master
Are you sure you want to change the base?
Solution #1706
Conversation
There was a problem hiding this 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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 .
No description provided.