Is there any order of dictionary value print in python? -
Is there any order of dictionary value print in python? -
this question has reply here:
why python ordering dictionary so? [duplicate] 3 answerswhen print values in dictionary, there default sorting utilize print keys , values in python dictionary? or randomly print key , value pairs?
please see below code. there order of dictionary value print in python?
confusion = {} confusion[1] = 1 confusion[4] = 22 confusion['5'] = 2 confusion['2'] = 2 confusion[1.0] = 4 confusion['1'] = 2 print confusion
the result {'2': 2, 1: 4, '1': 2, '5': 2, 4: 22}
quoting documentation:
cpython implementation detail: keys , values listed in arbitrary order non-random, varies across python implementations, , depends on dictionary’s history of insertions , deletions.
python dictionary
Comments
Post a Comment