Home >>Python String Methods >Python String lstrip() Method

Python String lstrip() Method

Python String lstrip() Method

Python string lstrip() method is used to remove any leading characters in the given input string. The default leading character to remove is space.

Syntax:
string.lstrip(characters)

Parameter Values

Parameter Description
characters This is an optional parameter. It defines a set of characters to remove as leading characters.
Here is an example of Python lstrip() method:

txt = "    mango    "
x = txt.lstrip()
print("of all fruits", x, "is my favorite")

Output:
of all fruits mango     is my favorite
Example 2:

txt = ",,,,,ssaaww.....Orange"
x = txt.lstrip(",.asw")
print(x)

Output:
Orange

No Sidebar ads