lstrip() Method



Description

Following is the syntax for lstrip() method −

Syntax

var.lstrip([chars])

Parameters

  • chars − You can supply what chars have to be trimmed.

Return Value

This method returns a copy of the string in which all chars have been stripped from the beginning of the string (default whitespace characters).

Example

The following example shows the usage of lstrip() method.

var = " Hello Python "
var1 = var.lstrip()
print ("original string:", var)
print ("lstripped string:", var1)

var = "0001234000"
var2 = var.lstrip('0')
print ("original string:", var)
print ("lstripped string:", var2)

var = '''
Welcome To
TutorialsPoint
'''
var3 = var.lstrip()
print ("original string:", var)
print ("lstripped:", var3)

When you run this program, it will produce the following output

original string:  Hello Python 
lstripped string: Hello Python 
original string: 0001234000
lstripped string: 1234000
original string: 
Welcome To
TutorialsPoint

lstripped: Welcome To
TutorialsPoint
split_and_join.htm
Advertisements