Python String strip() method

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

Syntax

Parameter

chars(optional): This parameter represents a string specifying the set of characters to be removed.

Return

This method returns a copy of the string with the leading and trailing characters removed.

Example 1

Output

Example 2

Output

Pin It on Pinterest

Share This