Easy Tutorial
❮ Python Os Removedirs Python Os Chflags ❯

Python3 lstrip() Method

Python3 Strings


Description

The lstrip() method is used to remove leading spaces or specified characters from the left side of a string.

Syntax

Syntax of the lstrip() method:

str.lstrip([chars])

Parameters

Return Value

Returns a new string with leading spaces or specified characters removed from the left side.

Example

The following example demonstrates the use of lstrip():

#!/usr/bin/python3

str = "     this is string example....wow!!!     ";
print( str.lstrip() );
str = "88888888this is string example....wow!!!8888888";
print( str.lstrip('8') );

Output of the above example:

this is string example....wow!!!     
this is string example....wow!!!8888888

Python3 Strings

❮ Python Os Removedirs Python Os Chflags ❯