Advertisement
# Signature of lstrip() method
lstrip()
# Python - Program to strip the leading blank spaces from a string using lstrip() method
# Creating a string
s1 = ' hello'
# Printing the original string
print('The value of string : ', s1)
# Calling the lstrip() method on string object
print('The stripped value of string : ', s1.lstrip())
The value of string : hello
The stripped value of string : hello
#Python - Method lstrip() does not remove the invoked string
# Creating a string
s1 = ' Deal with one difficult task at a time'
# Printing the original string
print('The value of string : ', s1)
# Calling the lstrip() method on string object
print('The stripped value of string : ', s1.lstrip())
# Printing the original string after calling lstrip() method on it.
print('The value of string value : ', s1)
The value of string : Deal with one difficult task at a time
The stripped value of string : Deal with one difficult task at a time
The value of string value : Deal with one difficult task at a time
Advertisement
#Python - Another example of lstrip() method
# Creating a string
s1 = ' mother nature provides for everyone '
# Printing the original string
print('The value of string : ', s1)
# Result of calling lstrip() is made to reference by the reference of original string.
s1 = s1.lstrip()
# Old reference variable pointing to the new string
print('Stripped value of the string : ', s1)
The value of string : mother nature provides for everyone
Stripped value of the string : mother nature provides for everyone
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement