Home / Python / Reference / String methods

Python string lstrip() method

Remove spaces (or other characters) from the left end only.

Syntax

str.lstrip(chars=None)

Strings cannot change, so this returns a new string; keep it with s = s.lstrip(…).

Parameters

charsthe characters to remove

Return value

str

Example

Code

print(repr("   indented".lstrip()))
print("000123".lstrip("0"))

Output

'indented'
123

Related

Learn it step by step in the free lesson Strings, with exercises that check your answers.