On Sun, Sep 18, 2011 at 11:22 AM, Vincent Vande Vyvre < vincent.vandevy...@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
-- http://mail.python.org/mailman/listinfo/python-list