Python ltrim() function

Facebooktwitterredditpinterestlinkedinmailby feather

Python ltrim() function

The ltrim() function in PHP removes whitespace or other predefined characters from the beginning or left side of a string.

The related functions are as follows:

  • rtrim() – This function is used to remove whitespace or other predefined characters from the right side of the given string
  • trim() – This function is used to remove whitespace or other predefined characters from both sides of the given string.

Syntax

Parameter

str(required)- This parameter specifies the string to check

character_mask(optional)- This parameter specifies which characters to remove from the string.

Return

This function returns a string with whitespace stripped from the beginning of str. If the second parameter is not specified, ltrim() will strip all of the following characters:

  • ” ” – an ordinary space.
  • “\t”- a tab.
  • “\n” – a new line (line feed).
  • “\r”- a carriage return.
  • “\0”- the NUL-byte.
  • “\x0B” – a vertical tab.

Example 1

Output

Example 2

Output

Example 3

Output

Facebooktwitterredditpinterestlinkedinmailby feather