Answers for "get list from ordered map python"

0

get first element of ordereddict

list(ordered_dict.items())[0]
Posted by: Guest on April-28-2020
1

ordered dictionary python

import collections

print 'Regular dictionary:'
d = {}
d['a'] = 'A'
d['b'] = 'B'
d['c'] = 'C'
d['d'] = 'D'
d['e'] = 'E'

for k, v in d.items():
    print k, v

print 'nOrderedDict:'
d = collections.OrderedDict()
d['a'] = 'A'
d['b'] = 'B'
d['c'] = 'C'
d['d'] = 'D'
d['e'] = 'E'

for k, v in d.items():
    print k, v
Posted by: Guest on October-21-2020

Python Answers by Framework

Browse Popular Code Answers by Language