I may be misunderstanding, but it sounds like = is not acceptable in the final result, so it's not enough to remove only 2 of 4 ='s. You want to make sure nothing messed up your string. So if the code existed, what you'd want is:
```
assert salt.count("=") <= 2
salt = salt.rstrip("=", "")
assert "=" not in salt
```
I think the code I'd want, if the new parameter existed, would be:
salt = salt.rstrip("=", maxstrip=2)
assert not salt.endswith("=")
That feels *slightly* better than your version. This version would allow there to be '=' in the middle of the string (albeit, such would not be base64, but some other kind of thing). Obviously, I've managed to program Python without this switch for 20+ years. But I think I'd use it occasionally.
Currently, I'd probably program my intention like this. Let's assume this is something where the '=' is allowed in the middle.
if salt.endswith("=="):
salt = salt[-2:]
elif salt.endswith("="):
salt = salt[-1:]
assert not salt.endswith("=")
The version you suggested, as mentioned, would not handle a format where '=' was permitted in the middle.
--
The dead increasingly dominate and strangle both the living and the
not-yet born. Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.