{"id":24478,"date":"2021-10-17T18:48:42","date_gmt":"2021-10-17T13:18:42","guid":{"rendered":"https:\/\/python-programs.com\/?p=24478"},"modified":"2021-11-05T19:25:29","modified_gmt":"2021-11-05T13:55:29","slug":"python-string-lstrip-method-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-string-lstrip-method-examples\/","title":{"rendered":"Python String lstrip() Method Examples"},"content":{"rendered":"

In the previous article, we have discussed Python Program for ljust() Function<\/a>
\nlstrip() Function in Python:<\/strong><\/p>\n

Any leading characters are removed using the lstrip() method (space is the default leading character to remove)<\/p>\n

Syntax:<\/strong><\/p>\n

string.lstrip(characters)<\/pre>\n

Parameters<\/strong><\/p>\n

characters:<\/strong> This parameter is optional, and omitting it causes the lstrip function to treat white spaces as the default parameter. In Python, specify the Characters to strip from the left-hand side of a string to change the default white space.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given first String =  \"####python###\"\r\nGiven character = '#'<\/pre>\n

Output:<\/strong><\/p>\n

The above given first string is : ####python###\r\nThe given first string after applying lstrip() function: python###<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given second String = \"@@@@@###_GOODMORNING_22222\"\r\nGiven characters = \"@,#\"<\/pre>\n

Output:<\/strong><\/p>\n

The above given second string is : @@@@@###_GOODMORNING_22222\r\nThe given second string after applying lstrip() function: _GOODMORNING_22222<\/pre>\n

Program for lstrip() Function in Python<\/h2>\n