formatting list -> comma separated

Jerry Hill malaclypse2 at gmail.com
Wed Jul 9 15:33:50 EDT 2008


On Wed, Jul 9, 2008 at 3:23 PM, Robert <rw.segaar at xs4all.nl> wrote:
> given d:
> d = ["soep", "reeds", "ook"]
>
> I want it to print like
> soep, reeds, ook

use the join() method of strings, like this:
>>> d = ["soep", "reeds", "ook"]
>>> ', '.join(d)
'soep, reeds, ook'
>>> d = []
>>> ', '.join(d)
''
>>>

-- 
Jerry



More information about the Python-list mailing list