Write a dictionary of lists to csv in Python

Viewed 3826

I have a dictionary like {a: [1, 2, 3], b: [4, 5, 6], c: [7, 3, 2]} and I would like to write this to a csv file in Python. I was the csv file as:

col1,col2,col3,col4
a,1,2,3
b,4,5,6
c,7,3,2

I tried using CSV Dict writer but I could not get as value is a list here.

Any help is appreciated!

6 Answers
Related