Python

Python Menu

Python

Python String startswith() - Definition, Syntax, Parameters, Examples

Definition

The startswith() method returns True if the string starts with the specified value, otherwise False.

Syntax

string.startswith(value, start, end)

Parameters

Parameter Description
value Required. The value to check if the string starts with
start Optional. An Integer specifying at which position to start the search
end Optional. An Integer specifying at which position to end the search

Examples:

testStr = "Welcome to the Python tutorials." result = testStr.startswith("Welcome") print(result)
# using the start and end parameter testStr = "Welcome to the Python tutorials." result = testStr.startswith("the", 11, 26) print(result)

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods