-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathcreate-dictionary.py
More file actions
35 lines (30 loc) · 1.02 KB
/
create-dictionary.py
File metadata and controls
35 lines (30 loc) · 1.02 KB
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
'''
Create dictionary
100xp
The countries and capitals lists are again available in the script.
It's your job to convert this data to a dictionary where the country names are
the keys and the capitals are the corresponding values. As a refresher, here is a
recipe for creating a dictionary:
my_dict = {
"key1":"value1",
"key2":"value2",
}
In this recipe, both the keys and the values are strings.
This will also be the case for this exercise.
Instructions
-With the strings in countries and capitals, create a dictionary called europe with
4 key:value pairs. Beware of capitalization! Make sure you use lowercase characters everywhere.
-Print out europe to see if the result is what you expected.
'''
# Definition of countries and capital
countries = ['spain', 'france', 'germany', 'norway']
capitals = ['madrid', 'paris', 'berlin', 'oslo']
# From string in countries and capitals, create dictionary europe
europe = {
"spain":"madrid",
"france":"paris",
"germany":"berlin",
"norway":"oslo",
}
# Print europe
print(europe)