Trim specific leading and trailing characters from a string
I believe strip
is the pythonic way. It is usually the case when there is a builtin function.
There are a few builtin path manipulators available in the os
library. You might want to use them if one of the manipulators is a match for your use case.
Example of strip()
in action; in this case, removing a leading plus sign:
In [1]: phone_number = "+14158889999"
In [2]: phone_number.strip('+')
Out[2]: '14158889999'