add list value of a key in a dictionary python

Viewed 75

I have a following dictionary:

centroid = {'A': [1.0, 1.0], 'B': [2.0, 1.0]}

Using the above dictionary I am creating two different dictionaries and appending them to a list:

for key in centroids:
        clusters_list.append(dict(zip(key, centroids.get(key))))

However when I check my cluster_list I get the following data:

[{'A': 1.0}, {'B': 2.0}]

instead of [{'A': [1.0, 1.0]}, {'B': [2.0, 1.0]}]. How can i fix this?

2 Answers
Related