coverting list back to string
Erik Max Francis
max at alcyone.com
Mon Apr 21 15:45:35 EDT 2003
scn wrote:
> my quest: i know that output.write(remove) is not correct. you
> cannot use the 'write' method on a list.
Presumably you want to join the list back into a string, with something
like:
' '.join(remove)
or in general
S.join(L)
where S is a delimiter string and L is a sequence. Note that this may
have an surprising effect since L.split() with no argument will split on
_any_ block of whitespace, whereas ' '.join(L) will only join the parts
back with a single space:
>>> L = 'this has a lot of spaces'.split()
>>> ' '.join(L)
'this has a lot of spaces'
This may not bother you, but I thought I'd point it out as a clear
difference.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ The revolution will not televised
\__/ Public Enemy
Maths reference / http://www.alcyone.com/max/reference/maths/
A mathematics reference.
More information about the Python-list
mailing list