-
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 #890
base: master
Are you sure you want to change the base?
Solution #890
Conversation
app/main.py
Outdated
""" | ||
|
||
:param incoming_list: | ||
:return: |
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.
There is no need to use a docstring as it is a simple function
app/main.py
Outdated
persons_list = [] | ||
for part_of_list in incoming_list: | ||
name = part_of_list["name"] | ||
age = part_of_list["age"] | ||
person = Person(name, age) | ||
persons_list.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 to create a list ofPerson
app/main.py
Outdated
age = part_of_list["age"] | ||
person = Person(name, age) | ||
persons_list.append(person) | ||
for i, part_of_list in enumerate(incoming_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.
By using a more descriptive name like index
instead of i
you make your code more readable and help others understand the purpose of the loop variable
app/main.py
Outdated
if part_of_list.get("wife"): | ||
persons_list[i].wife = \ | ||
Person.people[part_of_list.get("wife")] | ||
if part_of_list.get("husband"): | ||
persons_list[i].husband = \ | ||
Person.people[part_of_list.get("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.
you can split lines without using backslashes by enclosing the expression in parentheses.
app/main.py
Outdated
# write your code here | ||
pass | ||
|
||
def create_person_list(incoming_list: list) -> 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.
def create_person_list(incoming_list: list) -> list: | |
def create_person_list(incoming_list: list) -> list: |
Let's rename variables because naming is so bad now
incoming_list -> people_data
persons_list -> people
part_of_list -> 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.
Also,
people - багато людей
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.
.
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.
Small fix)
app/main.py
Outdated
people = [Person(person["name"], person["age"]) | ||
for person in people_data] | ||
|
||
for index, part_of_list in enumerate(people_data): |
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.
part_of_list -> 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.
Good job!
No description provided.