Definition
The strip() method removes any leading and trailing characters (space is the default leading character to remove)
Syntax
string.strip(chars)
Parameters
Parameter | Description |
---|---|
chars | Optional. A set of characters to remove as leading/trailing characters |
Examples:
myStr = " Python "
result = myStr.strip()
print(result, " is a programming language.")
# removing leading and trailing characters other than spaces
myStr = ",,,,,rrttgg.....Python....rrr"
result = myStr.strip(",.grt")
print(result, " is a programming language.")