Web Analytics

Python str.strip() Method

String Method โ€ข Cleanup

The strip() method removes any leading (spaces at the beginning) and trailing (spaces at the end) characters (space is the default leading character to remove).

Syntax

string.strip(characters)

Parameters

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

Return Value

A string.

Example

Using the strip() method:

Output
Click Run to execute your code

Related Functions