-
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 27102023 #829
base: master
Are you sure you want to change the base?
Solution 27102023 #829
Conversation
app/main.py
Outdated
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"] |
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.
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.
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.
Still not fixed
app/main.py
Outdated
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"] |
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.
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
Person.people[pers1].wife =\ | ||
Person.people[Person.people[pers1].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.
Use ()
instead of \
for separating lines
app/main.py
Outdated
Person.people[pers1].husband =\ | ||
Person.people[Person.people[pers1].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.
Use ()
instead of \
for separating lines
Eduard, please see new version |
app/main.py
Outdated
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"] |
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 don't need to do in there, make it in second loop
Eduard, please see the last version |
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.