PythonStringrstrip
lstrip

rstripString

split

Removes trailing whitespace (or specified characters).

Syntax

str.rstrip(chars?)

Example

Enter values below to update the example in real time.

print
rstrip
text = "  hello world  "
print(text.rstrip())  # "  hello world"