my_str.lstrip(char)
char: (Optional ) char to be removed from left of the input string my_strmy_str=' Plus2net'
output=my_str.lstrip()
print(output) #Plus2net
# removes * from left
my_str='**plus2net'
output=my_str.lstrip('*')
print(output) #plus2net
# removes all char left of plus2net
my_str='**## welcome plus2net'
output=my_str.lstrip('*# welcome')
print(output) # plus2net
# removes from left only.
# Can't remove in between the string
my_str='22plus2net'
output=my_str.lstrip('2')
print(output) # plus2net
my_str='Rs 5000'
output=my_str.lstrip('Rs')
print(output) # 5000
my_str = "###***Hello"
print(my_str.lstrip("#*")) # Output: 'Hello'
price = "Rs 5000"
print(price.lstrip("Rs")) # Output: ' 5000'
num_str = "00012345"
print(num_str.lstrip("0")) # Output: '12345'
text = "***Python Programming"
print(text.lstrip("*")) # Output: 'Python Programming'
user_input = " Hello World!"
cleaned_input = user_input.lstrip()
print(cleaned_input) # Output: 'Hello World!'
All String methods
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.