Python Dictionaries
Dictionaries A dictionary is unordered set of key:value pairs, with unique keys enclosed within {} brackets. It can be initialized as d1 = {} d2 = dict() d3 = dict(key1=value1, key2=value2,…,keyN=valueM) d4 = dict(some_iterable) d5=dict(mapping_object) There are following methods dictionary object has:- dict.clear() Removes all items from the dictionary and return None. dict.copy() Returns shallow copy of dictionary. dict.fromkeys(k [,v]) Creates new dictionary with keys from k and optionally taking values equal to v, and v Defaults to None. dict.get(k, d) Returns value from dictionary whose key equal to k, else returns d, and d Defaults to None. dict.has_key(k) Returns true if dictionary has key k else False. NOTE: It is Removed From 3.x Version of Python dict.items() ...