{"id":25911,"date":"2021-12-16T09:20:34","date_gmt":"2021-12-16T03:50:34","guid":{"rendered":"https:\/\/python-programs.com\/?p=25911"},"modified":"2021-12-16T09:20:34","modified_gmt":"2021-12-16T03:50:34","slug":"python-collections-ordereddict-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-collections-ordereddict-method-with-examples\/","title":{"rendered":"Python collections OrderedDict() Method with Examples"},"content":{"rendered":"

OrderedDict:<\/strong><\/p>\n

An OrderedDict is a subclass of dictionary that remembers the order in which keys were first placed. The only distinction between dict() and OrderedDict() is:<\/p>\n

The sequence in which the keys are inserted is preserved by OrderedDict. A standard dict does not keep track of the insertion order, therefore iterating through it returns the items in any order. OrderedDict, on the other hand, remembers the order in which the elements are placed.<\/p>\n

Collections OrderedDict() Method with Examples in Python<\/h2>\n

i)OrderedDict vs Normal Dictionary Example<\/h4>\n

Approach:<\/strong><\/p>\n