[Tutor] how to strip whitespaces from a string.
Chad Crabtree
flaxeater at yahoo.com
Sat Oct 9 16:43:28 CEST 2004
Lloyd Kvam wrote:
>>>>s = " I am Learning Python "
>>>>''.join( s.split() )
>>>>
>>>>
>'IamLearningPython'
>
>
>
I guess it always helps to look a little closer at the documentation.
I
just looked this up and of course it's right there. This method is
best
because it will work on any whitespace.
s="""I
am
Learning
Python NOw!!!!
"""
print ''.join(s.split())
IamLearningPythonNOw!!!!
More information about the Tutor
mailing list