It returns True if string endswith given suffix and False if suffix is not same as given.

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

Suffix=Last element of string or any object you want to match.

Start=Starting index from where you want to start search.

End=Ending index

e.g a is string given below ending with letter ‘e’ .

a=’apple’

a.endswith(‘e’,0,5)

It will match ‘e’ to the last element of given string start from 0 to 5th index. If matches return True otherwise return False.

Output: True

how to use str.endswith in string python
Str.endswith

 

By SC

One thought on “Str.endswith”

Leave a Reply

Your email address will not be published. Required fields are marked *