Important Notice:

Course Content
The Calendar Module
Library Function/Predefined Functions
0/4
Sys Module
Library Function/Predefined Functions
0/2
OS Module
Library Function/Predefined Functions
0/2
Functions in Python (Chapter-10) M3-R5
About Lesson

strip():-

        The strip() method removes any leading, and trailing whitespaces. Leading means at the beginning of the string, trailing means at the end. You can specify which character(s) to remove, if not, any whitespaces will be removed.

Syntax:-                       string.strip(characters)

txt = ”     banana     “

x = txt.strip()

print(“of all fruits”, x, “is my favorite”)

Output

of all fruits banana is my favorite

txt = “,,,,,rrttgg…..banana….rrr”

x = txt.strip(“,.grt”)

print(x)

Output

banana

error: Content is protected !!