
lstrip() method –
The lstrip() method removes all the leading characters specified in the argument from the left and returns a copy of the string.
syntax –
string.lstrip([chars])
chars( optional) – Characters to be removed from the beginning of the string. By default if no characters are provided then python removes the all the leading white spaces from the left.
Examples –
In [1]: string1 = ' python '
In [2]: string1.lstrip()
Out[2]: 'python '
In [3]: string2 = 'python3'
In [4]: string2.lstrip('py')
Out[4]: 'thon3'
In [5]: string3 = '****python3****'
In [6]: string3.lstrip('*')
Out[6]: 'python3****'
Related Posts –
- Python String Method – Capitalize()
- Python String Method – title()
- Python String Method – center()
- Python String Method – count()
- Python String Method – startswith()
- Python String Method – endswith()
- Python String Method – find()
- Python String Method – index()
- Python String Method – isalnum()
- Python String Method – isalpha()
- Python String Method – isdecimal()
- Python String Method – isdigit()
- Python String Method – islower()
- Python String Method – istitle()
- Python String Method – isupper()
- Python String Method – join()
- Python String Method – lower()
- Python String Method – upper()
- Python String Method – swapcase()