k = '9\t10\t12314\t12\t13\t14\t'
print(k.rstrip('\t12\t13\t14\t'))
For this given code the output that I would've expected is:
9 10 12314
But the output that I obtain on running this code is:
9 10
Replacing 12314 with any sequence of integers from 1-4 leads to this same faulty output, but the moment it reaches an integer greater than 5 it stops stripping the string. For example if we added a 5 in between 12314:
k = '9\t10\t123514\t12\t13\t14\t'
print(k.rstrip('12\t13\t14\t'))
Leads to the output:
9 10 1235
An explanation of why this happens would be appreciated. I tried looking up the code for the rstrip() function but I didn't find anything useful, but that might just be because I don't dig through source code too often. Also, I have been able to recreate this in python 3.x as well as 2.x so as far as I know it isn't version-specific.