Or, get rid of the extra variable and do:
for i in m.items():
print i[0] + ',' + ",".join(i[1])
On 4/27/07, Bill Burns <[EMAIL PROTECTED]> wrote:
Srinivas Iyyer wrote:
> Dear group,
>
> I have a dictionary (huge) and there are 19K keys for
> this dictionary. The values for the could be a max 19K
> again.
>
> simpler version of it:
>
> mydict=
>
{'a':['apple','ant','anchor','arrow'],'b':['ball','baby',boy','bus'],'c':['cat','call']}
>
> in a different list, i have keys:
> mlist = ['a','b','c']
>
> I want to print in the following way:
> a,apple,ant,anchor,arrow
> b,ball,baby,boy,bus
> c,cat call
>
> I cannot think of a simple way to do that (may be a
> mental block). could any one help me please.
>
> Thanks
> srini
>
Try this:
for key in mlist: print '%s,%s' % (key, ','.join(mydict[key]))
Bill
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor