Sunday, May 19, 2013


Dictionaries are unordered collection of items that are stored and fetched by key!

c={} dictionary
c=[] list


set = get unique elements
enumerate = generate the sequence
dict= assembles the dictionary

 433: 'you_need',
 434: 'your_camera',
 435: 'your_entry',

if you want to invert :

;c_inv= dict([(value, key) for (key, value) in c.iteritems()] )

'you_need':  433
'your_camera', 434
'your_entry', 435 

if you want to search by value

[key for key,value in c.items() if value=='your_entry' ][0]


No comments:

Post a Comment