We know how to use get with a dict in python:
a={'k':'thevalue}
a.get('k', 'There is no such key in the dict')
a.get('m', 'There is no such key in the dict')
the first one get returns the corresponding value and the second one the default value.
How would you go about the following situation in one liner:
a={'k':{'first':'uno','second':'dos'}}
# this is peseudocode:
a.get('k.first', 'There is no such key in the dict')
a.get('k["first"]', 'There is no such key in the dict')
meaning if k
exists in the dict I want the content of the key value first, i.e. 'uno'
.