Take the 2-minute tour ×  Possible Duplicate: python .rstrip
removes one additional character  What is the problem here? it
seems that rstrip removes more than necessary in the one to the
last line of code.  s = 'LedArray.py'    share|improve this
question add comment  marked as duplicate by SimonJ, 一二三,
Constantinius, zoul, Cat Plus Plus Jan 5 '12 at 11:15   2
Answers  up vote 0 down vote accepted  rstrip takes "characters
to remove", not "exact substring to remove" argument. .py and
y.py are equivalent as sets. In fact, you could do y.p and it'd
still remove the same characters.  share|improve this answer add
comment  Notice that the second argument to rstrip() is a set of
characters, not a sequence. The characters to be removed do not
need to occur in the order given.  This also means that
rstrip('y.py') is exactly the same as rstrip('.py'), a character
can't be in the set twice.  share|improve this answer add
comment