Python String lstrip method with Example – Python Tutorial
9 months ago Lalit Bhagtani 0
In this tutorial, we will learn about python string lstrip method.
lstrip method :
This method returns a copy of the string in which all the occurrences of chars ( passed as an argument ) has been removed from the beginning ( left side ) of the string object on which method is called. If chars arguments is omitted or None, then chars argument defaults to whitespace.
Syntax : < String Object >.lstrip( [ chars ] ) : < String Object >
chars: characters to be removed.
# create one string and assign it to variable s1 s1 = ' lstrip example' # call lstrip() method on string s1 output = s1.lstrip() # print the value of variable output print(output) # create one string and assign it to variable s2 s2 = 'lstrip example' # call lstrip() method on string s2 by passing 'l' as an argument output = s2.lstrip('l') # print the value of variable output print(output)
That’s all for Python String lstrip method. If you liked it, please share your thoughts in comments section and share it with others too.