OrderedDict

Run Settings
LanguagePython
Language Version
Run Command
from collections import OrderedDict #### USING NORMAL DICTIONARY #### d1 = {} # creating dictionary d1['a'] = 'Apple' d1['b'] = 'Ball' d2 = {} # creating dictionary d2['b'] = 'Ball' d2['a'] = 'Apple' print(d1 == d2) # True # As dictionary stores key values not in specific(insertion) order, # hence if all keys and values are same then both are same #### USING ORDERED DICTIONARY #### od1 = OrderedDict() # creating ordered dictionary od1['a'] = 'Apple' od1['b'] = 'Ball' od2 = OrderedDict() # creating ordered dictionary d2['b'] = 'Ball' d2['a'] = 'Apple' print(od1 == od2) # False # As ordered dictionary stores key values in specific(insertion) order, # hence although all keys and values are same the dictionaries are not same
Editor Settings
Theme
Key bindings
Full width
Lines