forked from greenfox-zerda-lasers/trial-exam-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.py
More file actions
20 lines (17 loc) · 716 Bytes
/
5.py
File metadata and controls
20 lines (17 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
pirates = [
{'Name': 'Olaf', 'has_wooden_leg': False, 'gold': 12},
{'Name': 'Uwe', 'has_wooden_leg': True, 'gold': 9},
{'Name': 'Jack', 'has_wooden_leg': True, 'gold': 16},
{'Name': 'Morgan', 'has_wooden_leg': False, 'gold': 17},
{'Name': 'Hook', 'has_wooden_leg': True, 'gold': 20},
]
# Write a function that takes any list that contains pirates as in the example,
# And returns a list of names containing the pirates that has wooden leg and
# more than 15 gold
def get_pirates(pirate_list):
new_list = []
for pirate in pirate_list:
if pirate['has_wooden_leg'] == True and pirate['gold'] > 15:
new_list.append(pirate['Name'])
return new_list
print(get_pirates(pirates))