Copyright © tutorialspoint.com

Python String find() Method

previous next


Description:

This method determines if str occurs in string, or in a substring of string if starting index beg and ending index end are given.

Syntax:

str.find(str, beg=0 end=len(string))

Parameters:

Here is the detail of parameters:

Return Value:

It returns index if found and -1 otherwise.

Example:

#!/usr/bin/python

str1 = "this is string example....wow!!!";
str2 = "exam";

print str1.find(str2);
print str1.find(str2, 10);
print str1.find(str2, 40);

This will produce following result:

15
15
-1

previous next

Copyright © tutorialspoint.com