The strip() returns a copy of the string with both leading and trailing characters stripped. If nothing is passed as an argument to the strip() method, the set of white space characters is considered as characters. Parameters of the strip() function in Python The syntax of the strip() function is: string.strip(characters) To strip or trim any white space character(s) present at the start or end of a given string, use the method strip() on the string. The strip method will remove any trailing or leading of a given string including tab (\t) and return a new string. It removes the whitespaces from the beginning of the string, which is the left side. L-Strip – lstrip() does the opposite of the R-strip. Hence the name rstring() i.e removing the spaces only from the right side of the string. R-strip – The rstrip() outputs a new string with only the trailing spaces removed.Strip – When we use the strip() a new string is returned after removing any trailing spaces or leading spaces.
0 Comments
Leave a Reply. |