The endswith() method returns True if a string ends with the given suffix otherwise returns False.
str.endswith(suffix, start, end)
suffix : Suffix is nothing but a string which 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.
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.
It returns True if string ends with the given suffix otherwise returns False.
False True True True
True True False
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.