# Python String Method – strip()

### strip() method –

The strip() method removes that leading and trailing characters specified in argument from the string and returns a copy of it.

#### Syntax –

string.strip([chars])

chars (optional) – a set of characters to be removed from the string’s left and right part. By default if not argument passed then python removes all white spaces from both sides of the string.

### Example –

In [1]: string1 = '    sirens of the sea    '

In [2]: string1.strip()
Out[2]: 'sirens of the sea'

In [3]: string2 = '****python***********'

In [4]: string2.strip('*')
Out[4]: 'python'


#### Related Posts –

Rating: 1 out of 5.