My goal is to build a dictionary in Python. My code seems to work. However, when I attempt to append a value to a single key the value is appended to multiple keys. I understand this is because the fromkeys method assigns multiple keys to the same list. How do I create multiple keys from a list with each assigned to a unique array?
#Create an Array with future dictionary keys
x = ('key1', 'key2', 'key3')
#Create a Dictionary from the array
myDict = dict.fromkeys(x,[])
#Add some new Dictionary Keys
myDict['TOTAL'] = []
myDict['EVENT'] = []
#add an element to the Dictionary works as expected
myDict['TOTAL'].append('TOTAL')
print(myDict)
#{'key1': [], 'key2': [], 'key3': [], 'TOTAL': ['TOTAL'], 'EVENT': []}
#add another element to the Dictionary
#appending data to a key from the x Array sees the data appended to all the keys from the x array
myDict['key1'].append('Entry')
print(myDict)
#{'key1': ['Entry'], 'key2': ['Entry'], 'key3': ['Entry'], 'TOTAL': ['TOTAL'], 'EVENT':
# []}