strings.strip

Functions

strip(→ str)

Remove leading and trailing characters (whitespace by default) from a string.

Module Contents

strings.strip.strip(user_string: str, characters: str = ' \t\n\r') str

Remove leading and trailing characters (whitespace by default) from a string.

Args:

user_string (str): The input string to be stripped. characters (str, optional): Optional characters to be removed

(default is whitespace).

Returns:

str: The stripped string.

Examples:
>>> strip("   hello   ")
'hello'
>>> strip("...world...", ".")
'world'
>>> strip("123hello123", "123")
'hello'
>>> strip("")
''