logo

Python String Find() Method


Show

Description

The expandtabs() method in Python String returns a copy of the string where the tab characters ie. '\t' use spaces to expand, making use of the given tabsize (default 8) optionally.

Syntax

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

Parameters

  • str - This indicates the string that is to be searched.
  • beg - This is the beginning index, by default, it’s 0.
  • end - This is the ending index, and it is equal to the length of the string by default.

Return Value

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)

Result

15
15
-1

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.