I have tried looping through this list and the dictionary at its index. I intend to get the key-value pairs into a new dictionary.
travel_log = [
{
"country": "France",
"visits": 12,
"cities": ["Paris", "Lille", "Dijon"]
},
{
"country": "Germany",
"visits": 5,
"cities": ["Berlin", "Hamburg", "Stuttgart"]
},
]
new_dict = {}
for key in travel_log[0]:
new_dict = key
print(new_dict)
The code above just loops into it and adds the last key looped over to the new dictionary, meanwhile, I want all the key values "countries", "visits" and "cities" to be there.