I am extracting some values from a dictionary in order to create another dictionary as follows:
from collections import defaultdict
a_lis = []
b_lis = []
for d in response['A']:
a_lis.append(d['B'])
b_lis.append(d['C'])
print(a_lis)
print(b_lis)
defaultdict(None, zip(a_lis,b_lis))
I decided to use default dict because I would like to have repeated elements inside my final dictionary. However, when I run the above code I get this:
defaultdict(None,
{'Fruit': 'PAR',
'Brand': 'best',
'date': 'imorgon',
'type': 'true',
'class': 'Första klass',
'time': '2018-10-25',
'number': 10})
How can I take the second element of the tuple in order to get just:
{'Fruit': 'PAR',
'Brand': 'best',
'date': 'imorgon',
'type': 'true',
'class': 'Första klass',
'time': '2018-10-25',
'number': 10}
I tried to:
defaultdict(None, zip(a_lis,b_lis))[1]
However it is not working