newbie question: convert a list to one string
Robert Kern
rkern at ucsd.edu
Thu Aug 25 05:13:15 EDT 2005
martijn at gamecreators.nl wrote:
> H!
>
> I'm searching for the fastest way to convert a list to one big string.
>
> For example:
> test = ['test','test2','test3']
>
> print unlist(test)
>
>>test test2 test3 (string)
>
>
>
> I know I can make a loop like below but is that the fastest/best option
> ?
>
> def unlist(test):
> output=''
> for v in test:
> output = output+" "+v
> return output
' '.join(test)
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list
mailing list