Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Use list comprehension operators to extract age details #28

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

twemyss
Copy link

@twemyss twemyss commented Oct 22, 2020

@twemyss
Copy link
Author

twemyss commented Oct 27, 2020

Code from line 80 onwards of group.py saves the friend group as JSON, and then loads it. It then checks that the saved and loaded data was equal, and prints the result.

Answers UCL-RITS/rse-classwork-2020#11

Comment on lines +76 to +78
# Then an alternative where it's written as one line using list comprehension expressions
ages = [friend['age'] for friend in my_group.values() if [relation['type'] for relation in friend['relations']].count(Relation.FRIEND) >= 1]
# Print maximum and average
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants