Method Name:
rstrip
Method Signature:
rstrip([chars])
Method Overview:
- The rstrip() method removes trailing characters in a string as specified in the chars parameter and returns a new string object.
- All the characters specified in the chars parameter are matched against the last character of the string.
- If any of the characters specified in chars found as the last character it is removed.
- This process continues till the last character of the string is not a character specified in chars parameter
- If chars parameter is not provided, trailing white spaces will be removed
Output:
functionCall = "SortFunction()" functionName = functionCall.rstrip("()") print("Original string:{}".format(functionCall)) print("String obtained after removing trailing chars:{}".format(functionName)) |
Example:
Original string:SortFunction() String obtained after removing trailing chars:SortFunction |