How to convert this list to string?

Travis E. Oliphant oliphant.travis at ieee.org
Wed Oct 18 03:30:58 EDT 2006


Jia Lu wrote:
> Hi all
> 
>  I have a list like:
> 
>>>> list
> [1, 2, 3]
>>>> list[1:]
> [2, 3]
> 
> I want to get a string "2 3"
> 
>>>> str(list[1:])
> '[2, 3]'
> 
> How can I do that ?
> 

" ".join(str(x) for x in list)


-Travis




More information about the Python-list mailing list