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

add update #1656

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

add update #1656

wants to merge 1 commit into from

Conversation

bogdna21
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.

Thank you for your submission! Your implementation of the Person class and the create_person_list function is mostly correct and meets the task requirements. However, there are a few areas for improvement:

  1. Use of if Statements: Instead of using explicit checks like if "wife" in person_data and person_data["wife"]:, consider using the dict.get() method for cleaner code.

  2. Code Style: Enhance your code readability by using list comprehensions instead of traditional for loops when creating lists of Person instances.

  3. Error and Warning Messages: Currently, your code prints error and warning messages directly. It would be beneficial to handle these cases more gracefully, possibly by raising exceptions or logging the messages.

  4. Handling Non-Existent Relationships: While your code provides informative warning messages for non-existent relationships, consider implementing additional handling if a husband or wife is not found.

  5. Duplicate Person Handling: The check for an existing person with the same name is correct, but it only prints an error message. Consider raising an exception or handling this case more robustly.

These improvements will not only enhance the functionality of your code but also make it more robust and maintainable. Keep up the good work, and continue to refine your coding skills! 😊

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

people = {}

def __init__(self, name: str, age: int) -> None:
if name in Person.people:

Choose a reason for hiding this comment

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

The check for an existing person with the same name is correct, but it only prints an error message. Consider raising an exception or handling this case more robustly if needed.

Comment on lines +30 to +35
if "wife" in person_data and person_data["wife"]:
wife_name = person_data["wife"]
if wife_name in Person.people:
person.wife = Person.people[wife_name]
else:
print(f"Warning: Wife with name \"{wife_name}\" don't exist")

Choose a reason for hiding this comment

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

The warning message for a non-existent wife is informative, but consider whether additional handling is needed if the wife is not found.

Comment on lines +38 to +43
if "husband" in person_data and person_data["husband"]:
husband_name = person_data["husband"]
if husband_name in Person.people:
person.husband = Person.people[husband_name]
else:
print(f"Husband with name \"{husband_name}\" don't exist")

Choose a reason for hiding this comment

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

Similar to the wife check, the warning message for a non-existent husband is informative, but consider whether additional handling is needed if the husband is not found.

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