-
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 #807
base: master
Are you sure you want to change the base?
Solution #807
Conversation
app/main.py
Outdated
person_list = [] | ||
|
||
for dc in people: | ||
_ = Person(dc["name"], dc["age"]) |
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 list comprehension here.
app/main.py
Outdated
if "wife" in dc: | ||
if dc["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.
if "wife" in dc: | |
if dc["wife"] is not None: | |
if dc.get("wife"): |
app/main.py
Outdated
if "husband" in dc: | ||
if dc["husband"] 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.
if "husband" in dc: | |
if dc["husband"] is not None: | |
if dc.get("husband"): |
app/main.py
Outdated
person_list = [] | ||
|
||
_ = [Person(dc["name"], dc["age"]) for dc 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.
person_list = [] | |
_ = [Person(dc["name"], dc["age"]) for dc in people] | |
person_list = [Person(dc["name"], dc["age"]) for dc 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.
when i try this way in the end of test person_list has 2 copies for each 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.
If you delete person_list.append(Person.people[dc["name"]])
in 25 line, you will not have duplicates in person_list
app/main.py
Outdated
for i in person_list: | ||
print(i.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.
It is redundant code
app/main.py
Outdated
person_list = [] | ||
|
||
_ = [Person(dc["name"], dc["age"]) for dc 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.
If you delete person_list.append(Person.people[dc["name"]])
in 25 line, you will not have duplicates in person_list
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.
Good job
No description provided.