lstrip
stringRemoves whitespace from the left (beginning) of a string
Syntax
lstrip(string) Parameters
string (string) The string to left-strip
Returns
string String with leading whitespace removed
Examples
Input:
lstrip(" hello ") Output:
"hello " Input:
lstrip(" test") Output:
"test" Input:
" world" | lstrip Output:
"world" The lstrip() function removes whitespace (spaces, tabs, newlines) from only the beginning (left side) of a string, preserving trailing whitespace.
Usage
Use lstrip() when you need to remove leading whitespace while preserving trailing whitespace, such as when cleaning indented text or code.