Home » Python String | lstrip() method with Examples

Python String | lstrip() method with Examples

by Online Tutorials Library

Python String lstrip() Method

Python lstrip() method is used to remove all leading characters from the string. It takes a char type parameter which is optional. If parameter is not provided, it removes all the leading spaces from the string.

Signature

Parameters

chars (optional) : A list of chars

Return

It returns a string.

Let’s see some examples of lstrip() method to understand it’s functionality

Python String lstrip() Method Example 1

A simple program to understand use of lstrip method. See how it removes leading spaces.

Output:

 TutorAspire Tutoraspire   

Python String lstrip() Method Example 2

Here, we are adding some special chars to the string and applying lstrip to remove leading chars.

Output:

$$$$-Tutoraspire-$$$$  -Tutoraspire-$$$$  

Python String lstrip() Method Example 3

Output:

https://tutoraspire.com  tutoraspire.com  

Next TopicPython Strings

You may also like