[Tutor] how to strip whitespaces from a string.

Chad Crabtree flaxeater at yahoo.com
Fri Oct 8 20:09:50 CEST 2004


kumar s wrote:

>Thank you. 
> But I messed up my question. 
>s = "   I am learning python    "
>f = s.strip()
>f 
>'I am learning python'
>
>How can I get the ouput to:
>
>'Iamlearningpython'.
>
>  
>
How about this

s="   I am Learning Python    "
s="".join([x.strip() for x in s.split(' ')])
print s
IamLearningPython




		



More information about the Tutor mailing list