Python String startswith() Method

Returns True if the string starts with the specified substring. This is a case sensitive test.

Syntax

Python
string.startswith(value, start = None, end = None)

Parameters

ParameterDescription
value Required. The string value to search for at the start of the given string
start Optional. The index at which to start searching. The default is None, meaning the start of the string.
end Optional. The index at which to stop searching. The default is None, meaning the end of the string.

Example

Python
str = 'Hello World!'
print(str.startswith('He'))
print(str.startswith('he'))

Output

True
False