Python String startswith() MethodLast Updated : 2 Jan 2026 Python startswith() method returns either True or False. It returns True if the string starts with the prefix, otherwise False. It takes two parameters start and end. Start is a starting index from where searching starts and end index is where searching stops. Syntax of the Python String startswith() MethodIt has the following syntax: Parameters
Both start and end are optional parameters. ReturnIt returns boolean value either True or False. Different Examples for Python String startswith() methodLet's see some examples of startswith() method to understand it's functionality. Example 1Let's first create a simple example which prints True if the string starts with the prefix. Output: True Example 2If the string does not start with prefix, the method returns False. See the example below Output: False Example 3This method takes three parameters. The start and end index are optional. Here, we are passing start index only. Output: True Example 4It returns true if the string lie between start and end index starts from the prefix. An example is created to describe the process. Output: True False Next TopicPython Strings |
We request you to subscribe our newsletter for upcoming updates.