String Methods

str.lstrip()

Remove consecutive characters from the leading end until a character outside the allowed set is reached. With None or omitted chars, remove Python-defined whitespace. An explicit chars string supplies individual code points, not an exact prefix or suffix. Internal characters are retained. The original string is unchanged.

Formal Syntax & Structure

python syntaxpython
text.lstrip(chars=None, /)

Parameters & Attributes

NameTypeDescription
charsstr | NoneCharacters eligible for removal; None means whitespace.

Return Value

str

Trimmed text.

Working Example

Example Snippetpython
print(repr("!!name!!".lstrip("!")))print(repr(" x ".lstrip()))
Python Reference