Python rstrip not working...

Add a reply

Posted by Bakuriu 365 days ago:
I made my (newbie) script for this challenge and on my pc in creates exactly the same outputs of the solutions but when i upload it it seems like the "str.rstrip()" doesn't do anything...it doesn't give error but it sìdoesn't "strip" too...
some1 knows how to solve this? or the only solution is to delete manually the " " on the right?
Posted by hallvabo 365 days ago:
rstrip() works perfectly fine.
My guess is that you are doing something akin to

str.rstrip()
...
print str

This won't work, since strings in Python are immutable.
str.rstrip() does not modify str, but returns a new string, which is stripped of trailing whitespace. So you have to do something like

str = str.rstrip()
...
print str

Add a reply