-
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 #828
base: master
Are you sure you want to change the base?
Solution #828
Conversation
app/main.py
Outdated
result = [] | ||
|
||
for item in people: | ||
person = Person(name=item["name"], age=item["age"]) | ||
married_dict[item["name"]] = person | ||
result.append(person) |
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 a list comprehension for a more concise approach
app/main.py
Outdated
|
||
|
||
def create_person_list(people: list) -> list: | ||
# write your code here | ||
pass | ||
married_dict = {} |
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.
why do you need this dict?
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.
to make a connection between married people
app/main.py
Outdated
married_dict[item["name"]] = person | ||
result.append(person) | ||
|
||
for item 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 person
instead of item
for clarity
app/main.py
Outdated
result.append(person) | ||
|
||
for item in people: | ||
person_obj = married_dict[item["name"]] |
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.
You can create a variable for 'person' and then use it, instead of adding it to the dictionary
app/main.py
Outdated
Person.people.get(person["name"]).wife = \ | ||
Person.people.get(person["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.
you can avoid using a backslash by breaking the code into multiple lines using parentheses to indicate a continuation
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.
Well done!
No description provided.