-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionary.py
More file actions
43 lines (29 loc) · 1.1 KB
/
Dictionary.py
File metadata and controls
43 lines (29 loc) · 1.1 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
36
37
38
39
40
41
42
43
#Dictionary = a collection of {key.value} pairs
#ordered and changeable. No Duplicates
capitals = {"USA": "Washington D.C",
"India": "New Delhi",
"China": "Beijing",
"Russia": "Moscow"}
#print(dir(capitals))
#print(help(capitals))
#print(capitals.get("USA"))
#if capitals.get("Russia"):
# print("That capitals exists")
#else:
# print("That capital doesn't exist")
#capitals.update({"Germany": "Berlin"}) #Insert new key or update key value pair
#capitals.update({"USA": "New York"})
#capitals.pop("China") #Delete a pair
#capitals.popitem() #Will remove the latest key value pair wihin the Dictionary
#capitals.clear() #Clear the Dictionary
#keys = capitals.keys() #Get All the keys within the Dictionary but not the values
#for key in capitals.keys():
# print(key)
#values = capitals.values()
#print(values) #Get All the values within the Dictionary but not the keys
#for value in capitals.values():
# print(value)
#items = capitals.item()
#print(items)
for key, value in capitals.items():
print(f"{key}: {value}")