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 masloo5000
def two_teams(sailors):
#replace this for solution
team1=[]
team2=[]
names=sorted(sailors) #sorted zwraca posortowanÄ… listÄ™ kluczy
for x in names:
if sailors[x]<20 or sailors[x]>40: team1.append(x)
else: team2.append(x)
return [sorted(team1), sorted(team2)]
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. 18, 2018