-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnested_dictionary.py
More file actions
65 lines (55 loc) · 1.54 KB
/
Copy pathnested_dictionary.py
File metadata and controls
65 lines (55 loc) · 1.54 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
key: [List],
key2: {Dict},
}
visited_cities = {
"France": "Paris",
"Germany": "Berlin",
}
travel_log = {
"France": ["Paris", "Lille", "Dijon"],
"Germany": ["Berlin", "Hamburg", "Stuttgard"],
}
cities_visited = {
"France": {
"Paris": "Visited 2 times",
"Lille": "Visited 1 time",
"Dijon": "Visited 4 times",},
"Germany": {
"Berlin": "Visited 1 time",
"Hamburg": "Visited 3 times",
"Stuttgard": "Visited 5 times",},
}
travel_log_v2 = {
"France": {"cities_visited_v2": ["Paris", "Lille", "Dijon"], "total_visits": 5},
"Germany": {"cities_visited_v2": ["Berlin", "Hamburg", "Stuttgard"], "total_visits": 5},
}
travel_log_list = [
{
"country": "France",
"cities_visited_v2": ["Paris", "Lille", "Dijon"],
"total_visits": 5,
},
{
"country": "Germany",
"cities_visited_v2": ["Berlin", "Hamburg", "Stuttgard"],
"total_visits": 5,
},
]
def add_new_country(country_visited, times_visited, cities_visited):
new_country = {}
new_country["country"] = country_visited
new_country["cities_visited"] = times_visited
new_country["cities_visited"] = cities_visited
travel_log_list.append(new_country)
add_new_country("Russian", 2, ["Moscow", "Saint Petersburg"])
print(visited_cities)
print(travel_log)
print(cities_visited)
order = {
"starter": {1: "Salad", 2: "Soup"},
"main": {1: ["Burger", "Fries"], 2: ["Steak"]},
"dessert": {1: ["Ice Cream"], 2: []},
}
print(order["main"][2]) #Prints the content of the variable
print(order["main"][2][0]) #Prints the string inside the variable