-
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
py-person-class Solution #764
base: master
Are you sure you want to change the base?
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.
Well done
app/main.py
Outdated
Person(person["name"], person["age"]) | ||
) | ||
for i in range(len(Person.people)): | ||
if "wife" in people[i].keys() and people[i]["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 just dict.get() method in the condition, instead of this long one
app/main.py
Outdated
if "wife" in people[i].keys() and people[i]["wife"] is not None: | ||
Person.people.get(people[i]["name"]).wife \ | ||
= Person.people.get(people[i]["wife"]) | ||
elif "husband" in people[i].keys(): |
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.
same about condition
app/main.py
Outdated
person_list.append( | ||
Person(person["name"], person["age"]) | ||
) | ||
for i in range(len(Person.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.
No need to use range + len here, u can iterate through items
app/main.py
Outdated
) | ||
for i in range(len(Person.people)): | ||
if "wife" in people[i].keys() and people[i]["wife"] is not None: | ||
Person.people.get(people[i]["name"]).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.
Don't use \
as a linebreaker, create temporary variable instead or use parentheses
app/main.py
Outdated
Person.people.get(people[i]["name"]).wife \ | ||
= Person.people.get(people[i]["wife"]) | ||
elif "husband" in people[i].keys(): | ||
Person.people.get(people[i]["name"]).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.
same about \
# 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.
Try to rewrite in one line. Hint: list comprehension 🤫
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.
done
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.
GJ 🚀 🚀 🚀
No description provided.