Posts

Showing posts with the label orderdict

OrderedDict in Python

Image
   Concept An  OrderedDict  is a dictionary subclass that remembers the order that keys were first inserted. OrderedDict  preserves the order  in which the keys are inserted. A regular dict doesn’t track the insertion order and iterating it gives the values in an arbitrary order. Code from collections import OrderedDict od = OrderedDict() od['1'] = 5 od['2'] = 4 od['3'] = 3 od['4'] = 2 od['5'] = 1 Get Help