The lstrip( ) Function is used to remove any unwanted character from the left side of the String with Space by default.
x = " Hello " y = x.lstrip() print(y,"World")
In the above code, we have declared a String ' Hello ' with leading and trailing spaces.
Then we have used the 'lstrip( )' function to remove the unwanted spaces from left side only.
So, the unwanted spaces are stripped out from the left side of the String.
Now, let us say you want the fill the right blocks with something other than spaces.
x = "*@Hello@ir" y = x.lstrip('@*') print(y)
In the above code, we have declared a String '*@Hello@ir' with some unwanted characters (i.e.'*, @') on the left side.
So, we have used the 'lstrip( )' function to remove the unwanted characters i.e. '*, @' from the left side only.
And '@' and '*' are stripped out only from the left side of the String.