Python String lstrip() Method
Python lstrip() method is used to get a copy of the string from which all leading characters or white spaces on the left side of the string have been removed. By default, it removes white spaces.
|characters(optional)||Parameter is a string containing characters to be removed from the beginning of the string. if not mentioned, white spaces are removed|
The lstrip() returns a string with all leading characters(given as argument) or white spaces removed
The following example you can see that, in the output of the lstrip() method, leading white space characters have been removed from string
# Python example of the lstrip() method, string = " tutorialsnation" # Removes spaces from left. print(string.lstrip())
The following example removes multiple characters from beginging of the string
# Python example of the lstrip() method, string = "$x++==--a@vtutorialsnation" # Removes spaces from left. print(string.lstrip("$x+=-a@"))