PythonStringendswith
startswith

endswithString

count

Returns True if the string ends with the specified suffix.

Syntax

str.endswith(suffix, start?, end?)

Example

Enter values below to update the example in real time.

filename
print
endswith
filename = "report.pdf"
print(filename.endswith(".pdf"))  # True
print(filename.endswith(".txt"))  # False