Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Ship Teams by Vojtas
def two_teams(sailors):
a=[[],[] ]
for sailor in sailors.keys():
if sailors[sailor]>40 or sailors[sailor]<20:
a[0].append(sailor)
else:
a[1].append(sailor)
#print(1,a[0],1)
a[0]=sorted(a[0])
a[1]=sorted(a[1])
print(1, a, 1)
return a
if __name__ == '__main__':
print("Example:")
print(two_teams({'Smith': 34, 'Wesson': 22, 'Coleman': 45, 'Abrahams': 19}))
#These "asserts" using only for self-checking and not necessary for auto-testing
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']
]
print("Coding complete? Click 'Check' to earn cool rewards!")
Nov. 17, 2018