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
| chars | the 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.