Important Notice:

Course Content
The Calendar Module
Library Function/Predefined Functions
0/4
Sys Module
Library Function/Predefined Functions
0/2
OS Module
Library Function/Predefined Functions
0/2
Functions in Python (Chapter-10) M3-R5
About Lesson

find:-

            The find() method finds the first occurrence of the specified value. The find() method returns -1 if the value is not found. The find() method is almost the same as the index() method, the only difference is that the index() method raises an exception if the value is not found. (See example below)

Syntax:-       string.find(value, start, end)

txt = “Hello, welcome to my world.”

x = txt.find(“e”)

print(x)

# 1

txt = “Hello, welcome to my world.”

x = txt.find(“e”, 5, 10)

print(x)                

# 8

txt = “Hello, welcome to my world.”

print(txt.find(“q”))        # -1

print(txt.index(“q”))       # valueError

error: Content is protected !!