Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
set comprehension + symmetric_difference + sorted solution in Creative category for The Ship Teams by Merzix
def two_teams(sailors):
young_and_old = {x for x,y in sailors.items() if y<20 or y>40}
others = sailors.keys() ^ young_and_old
return [sorted(young_and_old), sorted(others)]
if __name__ == '__main__':
assert two_teams({
'Smith': 34,
'Wesson': 22,
'Coleman': 45,
'Abrahams': 19}) == [
['Abrahams', 'Coleman'],
['Smith', 'Wesson']
]
assert two_teams({
'Fernandes': 18,
'Johnson': 22,
'Kale': 41,
'McCortney': 54}) == [
['Fernandes', 'Kale', 'McCortney'],
['Johnson']
]
Sept. 1, 2018
Comments: