Python has a method startswith(string) in the String class. This method accepts a prefix string that you want to search and is called on a string object. You can call this method in the following way −
>>> 'hello world'.startswith('hell') True >>> 'hello world'.startswith('nope') False
Similarly, there is an end with a method that accepts a suffix string that you want to search at the end of the given string. For example,
>>> 'hello world'.endswith('orld') True >>> 'hello world'.endswith('nope') False