Python String endswith() Method
Returns true if the string ends with the specified character or substring. The comparison is case-sensitive.
Syntax
Python
Copy Code
string.endswith(value, start = None, end = None)
Parameters
Parameter | Description |
---|---|
value |
Required. The string value to search for within the given string |
start |
Optional. The index at which to start searching. The default is None, meaning 0. |
end |
Optional. The index at which to stop searching. The default is None meaning the end of the string. |
Example
Python
Copy Code
str = 'The quick brown fox jumped over the lazy dog' print(str.endswith('dog')) print(str.endswith('Dog'))
Output
True False