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

Solution 27102023 #829

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

Conversation

Anton-Konyk
Copy link

No description provided.

app/main.py Outdated
Comment on lines 13 to 18
for pers in people1:
pers_inst = Person(pers["name"], pers["age"])
if "wife" in pers and pers["wife"] is not None:
pers_inst.wife = pers["wife"]
elif "husband" in pers and pers["husband"] is not None:
pers_inst.husband = pers["husband"]

Choose a reason for hiding this comment

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

Firstly, you need just create all instances of Person without assign a husband and a wife. You can add the created instances to output_list. And the last, you can use a list comprehension instead of the loop.

Choose a reason for hiding this comment

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

Still not fixed

app/main.py Outdated
Comment on lines 13 to 18
for pers in people1:
pers_inst = Person(pers["name"], pers["age"])
if "wife" in pers and pers["wife"] is not None:
pers_inst.wife = pers["wife"]
elif "husband" in pers and pers["husband"] is not None:
pers_inst.husband = pers["husband"]

Choose a reason for hiding this comment

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

Suggested change
for pers in people1:
pers_inst = Person(pers["name"], pers["age"])
if "wife" in pers and pers["wife"] is not None:
pers_inst.wife = pers["wife"]
elif "husband" in pers and pers["husband"] is not None:
pers_inst.husband = pers["husband"]
for pers in people1:
pers_inst = Person(pers["name"], pers["age"])
output_list.append(pers_inst)

app/main.py Outdated
Comment on lines 21 to 22
Person.people[pers1].wife =\
Person.people[Person.people[pers1].wife]

Choose a reason for hiding this comment

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

Use () instead of \for separating lines

app/main.py Outdated
Comment on lines 24 to 25
Person.people[pers1].husband =\
Person.people[Person.people[pers1].husband]

Choose a reason for hiding this comment

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

Use () instead of \for separating lines

@Anton-Konyk
Copy link
Author

Eduard, please see new version

app/main.py Outdated
Comment on lines 17 to 20
if "wife" in pers and pers["wife"] is not None:
output_list[-1].wife = pers["wife"]
elif "husband" in pers and pers["husband"] is not None:
output_list[-1].husband = pers["husband"]

Choose a reason for hiding this comment

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

You don't need to do in there, make it in second loop

@Anton-Konyk
Copy link
Author

Eduard, please see the last version

Copy link

@EdAlekseiev EdAlekseiev left a comment

Choose a reason for hiding this comment

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

Good job

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.

2 participants