파이썬/exercise
9-2. python dictionary in list
태지쌤
2023. 1. 4. 17:23
반응형
travel_log = [
{
"country": "France",
"visits": 12,
"cities": ["Paris", "Lille", "Dijon"]
},
{
"country": "Germany",
"visits": 5,
"cities": ["Berlin", "Hamburg", "Stuttgart"]
},
]
#🚨 Do NOT change the code above
#TODO: Write the function that will allow new countries
#to be added to the travel_log. 👇
def add_new_country(contry, count, city):
new_dictionary = {}
new_dictionary["country"] = contry
new_dictionary["visits"] = count
new_dictionary["cities"] = city
travel_log.append(new_dictionary)
#🚨 Do not change the code below
add_new_country("Russia", 2, ["Moscow", "Saint Petersburg"])
print(travel_log)
반응형