lstrip()

Removes space or chars from left side of the string
my_str.lstrip(char)
char: (Optional ) char to be removed from left of the input string my_str
Returns the string after removing chars from left of the string.
my_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

Example 1: Removing Multiple Characters

my_str = "###***Hello"
print(my_str.lstrip("#*"))  # Output: 'Hello'

Example 2: Cleaning User Input

price = "Rs 5000"
print(price.lstrip("Rs"))  # Output: ' 5000'

Example 3: Removing Leading Zeros

num_str = "00012345"
print(num_str.lstrip("0"))  # Output: '12345'

Example 4: Removing Specific Characters

text = "***Python Programming"
print(text.lstrip("*"))  # Output: 'Python Programming'

Example 5: Removing Whitespaces from User Input

user_input = "   Hello World!"
cleaned_input = user_input.lstrip()
print(cleaned_input)  # Output: 'Hello World!'
All String methods


Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer