list to string

Nick Welch mack at incise.org
Fri Sep 5 22:16:56 EDT 2003


On Sat, Sep 06, 2003 at 04:06:52AM +0200, Lars Behrens wrote:
> Can someone point me a way to change a list with arbitrary number of 
> items to a string :
> 
>   vals = ['aaa', 'bbb', 'ccc']
>   valstring = 'aaa, bbb, ccc'
> 
> Seems easy at the first glance, but...

>>> vals = ['aaa', 'bbb', 'ccc']
>>> valstring = ", ".join(vals)
>>> valstring
'aaa, bbb, ccc'
>>> 

:)

HTH,
-- 
Nick Welch aka mackstann | mack @ incise.org | http://incise.org
The income tax has made more liars out of the American people than golf
has.  Even when you make a tax form out on the level, you don't know
when it's through if you are a crook or a martyr.
		-- Will Rogers





More information about the Python-list mailing list