Get the latest tech news
Python Gotcha: strip, lstrip, rstrip can remove more than expected
The Python strip, lstrip, and rstrip functions can have unexpected behavior. Even though this is documented, non-default values passed to these functions can lead to unexpected results and how Python 3.9 solved this with two new functions.
In this case it is all letters in my last name, plus the space character: wegner Lower case all letters in the input string, resulting in andrew wegner From the right hand side of the string, begin removing characters that are in the input list. In this case that means that rengew wer are removed (right to left) and then the d in andrew is encountered so that rstrip function stops. In the PEP, it explicitly calls out the confusion users have about the*strip() functions and how they behave.
Or read this on Hacker News