ReferenceString methods
str.endswith()
Whether the string ends with the given text, or any of several.
Signature
text.endswith(suffix)Parameters
| Name | Means |
|---|---|
suffix | a string, or a tuple of strings |
Returns
A bool.
Example
Python
for name in ["a.png", "b.txt"]:
print(name, name.endswith((".png", ".jpg")))Output
a.png True b.txt False