How to access nested dictionary in python. I want to access 'type' of both card and card1.
data = {
'1': {
'type': 'card',
'card[number]': 12345,
},
'2': {
'type': 'wechat',
'name': 'paras'
}}
I want only type from both the dictionary. how can i get. I use the following code but getting error:
>>> for item in data:
... for i in item['type']:
... print(i)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: string indices must be integers