1. Description of endswith() method
The Python string endswith() method returns True if the string ends with the specified suffix, otherwise returns False, optionally restricting matching with the given start and end indices.
2. Syntax, parameters & Examples
Syntax
string.endswith(suffix[, start[, end]])
Parameters
- suffix: this is a string or tuple of suffixes to search for.
- start: the test starts from this index.
- end: end: ends here.
Return value
TRUE if the string ends with the specified suffix, otherwise FALSE.
Example
str = "Python Programming";
suffix = "ing";
print(str.endswith(suffix))
print(str.endswith(suffix,10))
suffix = "gra";
print(str.endswith(suffix, 4, 13))
print(str.endswith(suffix, 2, 10))
"""
attach:
True
True
True
False
"""
Younes Derfoufi
my-courses.net
my-courses.net
I agree with your point of view, your article has given me a lot of help and benefited me a lot. Thanks. Hope you continue to write such excellent articles.