The endswith() method of Python String returns True if the string tends to end with the specified suffix, else it returns False that optionally restricts the matching with the provided indices start and end.
str.endswith(suffix[, start[, end]])
TRUE if the string ends with the specified suffix, otherwise FALSE.
#!/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)
True True True False
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.