lawlermd (1) [Avatar] Offline

Your example is section 6.4.3:

x = ""

Why doesn't python strip out the "o" in "python"?

Your result is the same one I get in Python, but it does not make sense.
What am I missing?


Message was edited by:
naomi.ceder (134) [Avatar] Offline
Re: Question about *.strip
The 'o' in "python" is safe because strip() will only remove characters from the ends of strings. So specifiying ".gorw" as the characters to strip is enough to remove both the "www." and the ".org", but that that leaves "python" which doesn't begin or end with any of ".gorw", so the stripping ends. If the characters to strip had been ".gnorw", then the result would have been "pyth", but there is no way that strip will remove characters from within a string.

I hope that makes sense?

And thanks for raising the question!