Python String endswith() Method Syntax

Syntax: str.endswith(suffix, start, end)

Parameters: 

  • suffix: Suffix is nothing but a string that needs to be checked. 
  • start: Starting position from where suffix is needed to be checked within the string. 
  • end: Ending position + 1 from where suffix is needed to be checked within the string.

Return: ReturnsTrue if the string ends with the given suffix otherwise return False.

Note: If start and end index is not provided then by default it takes 0 and length -1 as starting and ending indexes where ending index is not included in our search.

Python String endswith() Method

Python String endswith() method returns True if a string ends with the given suffix, otherwise returns False.

Similar Reads

Python String endswith() Method Syntax

Syntax: str.endswith(suffix, start, end) Parameters:  suffix: Suffix is nothing but a string that needs to be checked. start: Starting position from where suffix is needed to be checked within the string. end: Ending position + 1 from where suffix is needed to be checked within the string.Return: ReturnsTrue if the string ends with the given suffix otherwise return False....

Python String endswith() Method Example

Python3 string = "geeksforgeeks" print(string.endswith("geeks"))...