The lstrip() function in python removes the leading characters in the copy of the original string based on the arguments given. The method returns this copy as output.
string.lstrip([chars]) #where chars are those to remove as leading characters
The lstrip() function takes characters as its parameter. If chars are not provided the leading space is removed from the string.
|Parameter||Description||Required / Optional|
|chars||characters to remove as leading characters||Optional|
The return value is always a string. Until the first match found, all combinations of characters are removed from the left onwards.
|string||copy of string|
# Variable declaration string1 = " Python " # Leading whitepsace are removed print(string1.lstrip()) string2 = ",,,,,ssaaww.....programming" print(string2.lstrip(",.asw"))
# Variable declaration string1 = "$$$$-Python-$$$$" # Calling function string2 = string1.lstrip('$') # Displaying result print(string1) print(string2)