I have a dictionary that looks like this:
dictionary = {'Alice': ['10', '10'], 'Tom': ['9', '8'], 'Ben': ['10', '9']}
I have created a csv file using this dictionary by using the following code which I have taken & adapted from a previous post (How do I write a Python dictionary to a csv file?):
with open('test.csv', 'w') as file:
writer = csv.DictWriter(file, dictionary.keys(), lineterminator="\n")
writer.writeheader()
writer.writerow(dictionary)
This creates a csv file that looks like this:
Alice, Tom, Ben
['10', '10'], ['9', '8'], ['10', '9']
But I would like to create a csv file that looks like this:
Alice, ['10', '10']
Tom, ['9', '8']
Ben, ['10', '9']