making a string copy of a list

Pearu Peterson pearu at cens.ioc.ee
Sat Jan 13 03:06:19 EST 2001


On Sat, 13 Jan 2001, Tyler Eaves wrote:

> yourstring=''
> for x in yourlist:
> 	yourstring=yourstring+str(x)+','
> #Remove that last comma
> yourstring=yourstring[:-1]

`yourlist` should do the job:

>>> `[2,3]`
'[2, 3]'

or (almost) equivalent to Tyler's suggestion:

>>> `[2,3]`[1:-1]
'2, 3'

Pearu




More information about the Python-list mailing list