-
Notifications
You must be signed in to change notification settings - Fork 1
/
dict_basic
50 lines (40 loc) · 1.37 KB
/
dict_basic
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
39
40
41
42
43
44
45
46
47
48
49
rivers = {
'nile': 'egypt',
'yellow': 'china',
'zhu': 'china'
} ## dictionary item/// key/// value
for river, country in rivers.items():
print(river.title() + " is in " + country.title())
for river in rivers.keys():
print(river.title())
for country in rivers.values():
print(country.title())
print("\n")
sandwich_orders = ['good', 'black', 'white', 'tuna', 'black']
finished_sandwiches = []
while len(sandwich_orders) > 0:
sandwich = sandwich_orders.pop()
print("I made your " + sandwich + " sandwich")
finished_sandwiches.append(sandwich)
print("All the sandwiches I made are: ")
for sandwich in finished_sandwiches:
print("\t" + sandwich)
print('\n')
wars = [
{"war": "Italian Wars", "death-toll": 350000,
"start-year": 1494, "end-year": 1559},
{"war": "Spanish conquest of the Aztec Empire", "death-toll": 2300000,
"start-year": 1519, "end-year": 1632},
{"war": "German Peasants War", "death-toll": 100000,
"start-year": 1524, "end-year": 1525},
{"war": "Transition from Ming to Qing", "death-toll": 25000000,
"start-year": 1616, "end-year": 1683},
{"war": "Franco-Dutch War", "death-toll": 220000,
"start-year": 1672, "end-year": 1678}
]
### find a biggest value in a dict
with_biggest_toll= wars[0]
for war in wars:
if war['death-toll'] > with_biggest_toll['death-toll']:
with_biggest_toll= war
print(with_biggest_toll['war'])