Python String rstrip() MethodPython rstrip() method removes all the trailing characters from the string. It means it removes all the specified characters from right side of the string. If we don't specify the parameter, It removes all the whitespaces from the string. This method returns a string value. SignatureParameterschars: character to be removed from the string. ReturnIt returns string. Let's see some examples of rstrip() method to understand it's functionality. Python String rstrip() Method Example 1A simple example, does not take any parameter. It removes all the trailing whitespaces from the string. Output: Old string: Java and C# New String: Java and C# Python String rstrip() Method Example 2string chars are removed based on the char type parameter. It returns a string after removing the character. Output: Old string: Java and C# New String: Java and C Python String rstrip() Method Example 3It is pretty easy to know how many characters are removed by getting string length. See the example. String length is displayed along with string value. Output: Old string: Java and C# 11 New String: Java and C 10
Next TopicPython Strings
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week