반응형
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)
반응형
'파이썬 > exercise' 카테고리의 다른 글
10-1. python 딕셔너리와 함수 결합 (0) | 2023.01.05 |
---|---|
9-3. python blind auction (0) | 2023.01.04 |
9-1. python dictionary 성적 등급 매기는 프로그램 (0) | 2023.01.04 |
8-3. python caesar cipher (0) | 2023.01.04 |
8-2. python prime number checker (0) | 2023.01.04 |