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

py-person-class Solution #764

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

Conversation

RVChornyy
Copy link

No description provided.

Copy link

@kostomeister kostomeister left a 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:
Copy link

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():
Copy link

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)):
Copy link

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 \
Copy link

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 \
Copy link

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:
Copy link

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 🤫

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link

@fsocie7y fsocie7y left a comment

Choose a reason for hiding this comment

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

GJ 🚀 🚀 🚀

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.

3 participants