Skip to content Skip to sidebar Skip to footer

Merging Dictionary Into List Issues - Python

The problem I want to merge a dictionary onto the end of a list that I am generating using a For loop. It seems to work but the problem, is that the curly braces stay around the di

Solution 1:

Instead of appending to the tag_dicts which is a list, you should update your dictionary inside the list. So instead of below:

tag_dicts.append(tag.as_dict())
tag_dicts.append(musiccopy)

use the below to update the dictionary:

tag_dicts.append(tag.as_dict())
tag_dicts[0].update(musiccopy)

Post a Comment for "Merging Dictionary Into List Issues - Python"