Home >>Python String Methods >Python String endswith() Method

Python String endswith() Method

Python String endswith() Method

Python string endswith() method is used to return true if the string ends with the specified value otherwise it will return false.

Syntax:
string.endswith(value, start, end)

Parameter Values

Parameter Description
value This is a required parameter. It defines the value to check if the string ends with.
start This is an optional parameter. It defines an Integer specifying at which position to start the search.
end This is an optional parameter. It defines an Integer specifying at which position to end the search.
Here is an example of Python endwith() method:

txt = "Welcome to PHPTPOINT!!"
x = txt.endswith("!")
print(x)

Output:
True
Example 2:

txt = "Welcome to PHPTPOINT!!"
x = txt.endswith("POINT!!", 5, 11)
print(x)

Output:
False