-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 #1651
base: master
Are you sure you want to change the base?
Solution #1651
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.
Thank you for your hard work on this Pull Request! 😊 While your code meets most of the task requirements, there are a few critical issues that need to be addressed before we can approve it:
-
Use of
dict.get()
Method: It's important to usedict.get()
when accessing dictionary values to prevent potentialKeyError
exceptions. This will make your code more robust and easier to read. -
Handling
None
Assignments: When assigningperson.wife
orperson.husband
, ensure that these entries exist in thePerson.people
dictionary. AssigningNone
could lead to issues if not properly handled. -
Unique Names in
people
Dictionary: Make sure that the names used as keys in thepeople
dictionary are unique to prevent overwriting existingPerson
instances.
These changes are crucial for ensuring the functionality and reliability of your code. Once you've addressed these points, feel free to resubmit your Pull Request. Keep up the great work, and I'm looking forward to seeing your improvements! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
@@ -1,8 +1,28 @@ | |||
class Person: | |||
# write your code here | |||
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.
The people
dictionary is used to store Person
instances by their name. Ensure that names are unique to avoid overwriting existing entries.
person = Person(person_data["name"], person_data["age"]) | ||
|
||
if "wife" in person_data and person_data["wife"]: | ||
person.wife = Person.people.get(person_data["wife"]) |
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.
When assigning person.wife
, ensure that the wife
exists in the Person.people
dictionary. If not, this will result in None
, which could lead to issues if not handled properly.
person.wife.husband = person | ||
|
||
if "husband" in person_data and person_data["husband"]: | ||
person.husband = Person.people.get(person_data["husband"]) |
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.
Similarly, when assigning person.husband
, ensure that the husband
exists in the Person.people
dictionary to avoid potential None
assignments.
No description provided.