On 18/09/11 11:39, Kayode Odeyemi wrote: > Hi all, > > If I have a list with key/value pair, how do I get the value of the key? > > I'm working with this code snippet:
Python 3.2.2 (default, Sep 5 2011, 04:33:58) [GCC 4.6.1 20110819 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> lst = [ ('key1', 'value1'), ('key2', 'value2') ] >>> d = dict (lst) >>> d['key1'] 'value1' >>> > >>>> items = {'fees':[('status','pending'), ('timeout',60)], > 'hostel':[('status', > 'pending'), ('timeout','120')]} >>>> print [items[i] for i in items.keys()] > [[('status', 'pending'), ('timeout', '120')], [('status', 'pending'), > ('timeout' > , 60)]] >>>> > > -- > Odeyemi 'Kayode O. > http://www.sinati.com. t: @charyorde > > > -- http://mail.python.org/mailman/listinfo/python-list