Latest web development tutorials

Python3 lstrip () method

Python3 string Python3 string


description

lstrip () method is used to cut out spaces or a specified character string on the left.

grammar

lstrip () method syntax:

str.lstrip([chars])

parameter

  • chars - the specified character taken.

return value

Returns a new string resulting amputated left blank or specified character string after.

Examples

The following example shows lstrip () to use:

#!/usr/bin/python3

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

Examples of the above output results are as follows:

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

Python3 string Python3 string