list to string

L

Lars Behrens

Hi there!

I need help for cgi-script.

I've been fiddling around for quite a while, searched through lots of
doc. But I didn't get it:

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...

Tia
Lars
 
N

Nick Welch

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
 
N

Nicola Mingotti

Lars Behrens said:
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'

# here you import a lot of functions on strings
import string

vals = ['a','b','c']
valstring = string.join(vals,",")
Seems easy at the first glance, but...
.... it's :)

bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top