Trying to create a dictionary of two keys and having more then one value.
myList = [[('2016-11-01', 'USD'), 'ECB News'],
[('2016-11-01', 'USD'), 'FED News'],
[('2016-11-02', 'EUR'), 'Brexit News'],
[('2016-11-03', 'USD'), 'Yellen Speaking']]
myDict = defaultdict(lambda: defaultdict(list))
for d, value in myList:
print(d, value)
myDict[d].append(value) #<<<----- Error here
print(myDict)
getting Error:
myDict[d].append(value)
AttributeError: 'collections.defaultdict' object has no attribute 'append'
Expected output: Append same key pair values together.
{[('2016-11-01', 'USD'): 'ECB News', 'FED News'],
[('2016-11-02', 'EUR'): 'Brexit News'],
[('2016-11-03', 'USD'): 'Yellen Speaking']}