Python

Python Menu

Python

Python String rstrip() - Definition, Syntax, Parameters, Examples

Definition

The rstrip() method removes any trailing characters (characters at the end a string), space is the default trailing character to remove.

Syntax

string.rstrip(chars)

Parameters

Parameter Description
chars Optional. A set of characters to remove as trailing characters

Examples:

myStr = " Python " result = myStr.rstrip() print(result, " is a programming language.") # removing other trailing characters myStr = "Python,,,,,ssqqqww....." result = myStr.rstrip(",.qsw") print(result, " is a programming language.")

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods