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 |