python - Inverse order of dictionary values -


i have python dictionary following:

mydict = {'cb_rdbu_4': [['202', '0', '32'], ['244', '165', '130'], ['146', '197', '222'], ['5', '113', '176']]} 

i inverse order of elements in list. instance first key value list have following order:

'cb_rdbu_4': [['5', '113', '176'], ['146', '197', '222'], ['244', '165', '130'], ['202', '0', '32']] 

how do that?

new_dict = dict([(key,reversed(value)) key,value in mydict.items()]) 

or if want edit in place

for key in mydict:     mydict[key] = reversed(mydict[key]) 

instead of reversed(value) can value[::-1]


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -