I am trying to access the dictionary elements in python, which looks like this:
mydict= {'message':'','result':[{'abc':1,'xyz':2}]}
I want to access the value of key 'xyz'.Is there any direct method to access it in python.
Any help is greatly appreciated.
Advertisement
Answer
In steps,
mydict['result']returns[{'abc':1,'xyz':2}]mydict['result'][0]returns{'abc':1,'xyz':2}mydict['result'][0]['xyz']returns2