How to convert this list to string?
rrr at ronadam.com
Wed Oct 18 10:10:09 CEST 2006
Jia Lu wrote:
> Hi all
> I have a list like:
> [1, 2, 3]
> [2, 3]
> I want to get a string "2 3"
> '[2, 3]'
> How can I do that ?
Just to be different from the other suggestions...
>>> a = [1, 2, 3]
>>> str(a[1:]).strip('').replace(',', '')
By the way. It's a good idea to try not to use 'list' or other built-in names
for your own objects. Best to start with good habits so that you avoid odd hard
to find bugs later.
More information about the Python-list