Function Details: endswith

Description


Return True if the string ends with the specified suffix, False otherwise.


Extended Description


The endswith() method checks if the string ends with the specified suffix. It returns True if the string ends with the specified suffix and False otherwise. If a tuple of suffixes is provided, it returns True if the string ends with any of the suffixes. The optional start and end parameters allow you to check only a slice of the string.


Read More about endswith from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • suffix: Union[str, Tuple[str]]
  • start: int
  • end: int

Return


Returns a boolean indicating whether the string ends with the specified suffix.


Return Type


bool

Output

Explanation

This example demonstrates the basic usage of endswith(). It checks if the string ends with '.txt'.