-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathShip_Team.py
More file actions
38 lines (36 loc) · 952 Bytes
/
Ship_Team.py
File metadata and controls
38 lines (36 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def two_teams(sailors):
#replace this for solution
k = []
l = []
for name in sailors:
if sailors[name]<20 or sailors[name]>40:
l.append(name)
else:
k.append(name)
l.sort()
k.sort()
return [
l,
k
]
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']
# ]