rstrip
stringRemoves whitespace from the right (end) of a string
Syntax
rstrip(string) Parameters
string (string) The string to right-strip
Returns
string String with trailing whitespace removed
Examples
Input:
rstrip(" hello ") Output:
" hello" Input:
rstrip("test ") Output:
"test" Input:
"world " | rstrip Output:
"world" The rstrip() function removes whitespace (spaces, tabs, newlines) from only the end (right side) of a string, preserving leading whitespace.
Usage
Use rstrip() when you need to remove trailing whitespace while preserving leading whitespace, such as when cleaning line endings or formatted output.