Home >>Python String Methods >Python String strip() Method
Python string strip() method is used to remove any leading spaces at the beginning and trailing spaces at the end or any characters. Space is the default leading character to remove.
Syntax:string.strip(characters)
Parameter | Description |
---|---|
characters | This is an optional parameter. It defines a set of characters to remove as leading or trailing characters. |
txt = " PHPTPOINT "
x = txt.strip()
print("I work at", x, "as a Developer")
txt = ",,,,,rrttgg.....Jerry..******..rrr"
x = txt.strip(",*.grt")
print(x)