Getting a list value from key/value pair
Kayode Odeyemi
dreyemi at gmail.com
Sun Sep 18 08:44:50 EDT 2011
More information about the Python-list mailing list
Sun Sep 18 08:44:50 EDT 2011
- Previous message (by thread): Getting a list value from key/value pair
- Next message (by thread): Getting a list value from key/value pair
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Sep 18, 2011 at 11:22 AM, Vincent Vande Vyvre < vincent.vandevyvre at swing.be> wrote: > ** > Le 18/09/11 11:39, Kayode Odeyemi a écrit : > > items = {'fees':[('status','pending'), ('timeout',60)], > 'hostel':[('status', > 'pending'), ('timeout','120')]} > > Like that: > > # -*- coding: utf-8 -*- > > > items = {'fees':[('status','pending'), ('timeout',60)], > 'hostel':[('status', > 'pending'), ('timeout','120')]} > > for key, value in items.iteritems(): > print "\n {0}".format(key) > for val in value: > print "\t{0}: {1}".format(val[0], val[1]) > > for python 2.x > Vincent, with: values = ('status', 'pending') ('timeout', '120') ('status', 'pending') ('timeout', 60) How do I comma separate it and put each each item in a dict? >>> for key, value in items.iteritems(): ... for val in value: ... md = {} ... for q in val: ... md.update(q) ... print md ... Traceback (most recent call last): File "<stdin>", line 5, in <module> ValueError: dictionary update sequence element #0 has length 1; 2 is required Thank you -- Odeyemi 'Kayode O. http://www.sinati.com. t: @charyorde -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20110918/2ae66750/attachment-0001.html>
- Previous message (by thread): Getting a list value from key/value pair
- Next message (by thread): Getting a list value from key/value pair
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list