You are here : python_2stringstringendswith

string.endswith() - string

             

It returns True if the string ends with the specified suffix, otherwise return False optionally restricting the matching with the given indices start and end.


  • suffix -- This could be a string or could also be a tuple of suffixes to look for.

  • start -- The slice begins from here.

  • end -- The slice ends here.


Syntax


str.endswith(suffix[, start[, end]])


Example


#!/usr/bin/python

str = "this is string example....wow!!!";

suffix = "wow!!!";
print str.endswith(suffix)
print str.endswith(suffix,20)

suffix = "is";
print str.endswith(suffix, 2, 4)
print str.endswith(suffix, 2, 6)


Output / Return Value

TRUE if the string ends with the specified suffix, otherwise FALSE.


True True True False


Limitations


Alternatives / See Also


Reference