/* */

Thursday, 24 March 2011

-dict

The dict function creates a dictionary from other mappings (other dictionaries) or from sequences of pairs (key,value):
items =[('name', 'Jim'), ('age', 42)]
d= dict(items)
d
{'age' : 42, 'name' : 'Jim'}
d['name']
'Jim'

Also can be used with keyword argument:
d= dict(name= 'Jim', age= 42)
d
{'age' : 42,  'name' : 'Jim'}

No comments:

Post a Comment