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

Develop #1657

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

Develop #1657

wants to merge 4 commits into from

Conversation

pr-ruslan
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 hard work on this task! 😊 While your implementation is on the right track, there are a few critical issues that need to be addressed to fully meet the task requirements:

  1. Use of List Comprehension: The task recommends using list comprehension to create the list of Person instances. This will make your code more concise and efficient.

  2. Dictionary Access: To prevent potential KeyError exceptions, it's important to use the dict.get() method when accessing dictionary values. This will also simplify your code.

  3. Handling wife/husband Attributes: The current logic does not correctly handle the absence of wife or husband keys. Ensure that these attributes are set correctly according to the task requirements.

  4. Missing Attributes: Make sure to add the wife or husband attributes to the Person instances when these keys are present.

Please address these issues, and feel free to reach out if you need any help! Keep up the great work, and I look 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.

app/main.py Outdated


def create_person_list(people: list) -> list:
# write your code here
pass
person_list = []

Choose a reason for hiding this comment

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

Consider using list comprehension to create person_list as recommended in the checklist: person_list = [Person(name=person['name'], age=person['age']) for person in people].

app/main.py Outdated
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.

Use the dict.get() method to access dictionary values to avoid potential KeyError exceptions. For example, person.get('name') instead of person['name'].

app/main.py Outdated
Comment on lines 26 to 29
if "wife" in people[i]:
if not people[i]["wife"]:
continue
else:

Choose a reason for hiding this comment

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

Simplify the logic by using if people[i].get('wife'): instead of checking for the presence of the key and its value separately. This avoids nested if statements.

app/main.py Outdated
Comment on lines 32 to 34
elif not people[i]["husband"]:
continue
else:

Choose a reason for hiding this comment

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

Similarly, simplify the logic for checking the husband key by using elif people[i].get('husband'):.

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.

Review Summary

Great job on implementing the create_person_list function! 🎉 Your code meets the task requirements and constraints, which is a significant achievement. Here are some key points and suggestions for improvement:

  • Class Definition and Initialization: You've correctly defined the Person class with the necessary __init__ method, and you're using the class attribute people effectively to store instances by their name.

  • List Comprehension: The use of list comprehension in the create_person_list function is well done, creating a list of Person instances from the input list of dictionaries.

  • Dictionary Access: Good job using the dict.get() method to access the wife and husband keys, which helps prevent potential KeyError exceptions.

  • Handling wife/husband Attributes: While you have made progress, the logic for setting the wife and husband attributes needs a bit more attention. Ensure that both attributes are set correctly according to the task requirements. This is crucial for the functionality of the code.

Although there are some issues to address, particularly with the handling of wife and husband attributes, the decision is to APPROVE this pull request to help you move forward with your learning. Please review the comments and make the necessary improvements to enhance your code. Remember, addressing these issues will help you avoid similar problems in the future. Keep up the great work and continue learning from your experiences! 🚀

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

Comment on lines +22 to +26
pair_name = people[i].get("wife")
if pair_name:
person.wife = get_partner_pointer(pair_name)
elif people[i].get("husband"):
person.husband = get_partner_pointer(people[i].get("husband"))

Choose a reason for hiding this comment

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

The current logic for setting the wife and husband attributes is not entirely correct. According to the task requirements, if a person has a wife, the wife attribute should be set, and if a person has a husband, the husband attribute should be set. The current logic only sets one of these attributes based on the presence of the keys. Consider revising this logic to ensure both attributes are handled correctly.

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