Copyright © tutorialspoint.com

Python String startswith() Method

previous next


Description:

This method checks whether string starts with str, optionally restricting the matching with the given indices start and end.

Syntax:

str.startswith(str, beg=0,end=len(string));

Parameters:

Here is the detail of parameters:

Return Value:

It returns true if found matching string otherwise false.

Example:

#!/usr/bin/python

str = "this is string example....wow!!!";
print str.startswith( 'this' );
print str.startswith( 'is', 2, 4 );
print str.startswith( 'this', 2, 4 );

This will produce following result:

True
True
False

previous next

Copyright © tutorialspoint.com