Home >>Python String Methods >Python String find() Method
Python string find() method is used to find the first occurrence of the required value. It returns -1 if the required value is not found.
Syntax:string.find(value, start, end)
Parameter | Description |
---|---|
value | This is a required parameter. It defines the value to search for. |
start | This is an optional parameter. It defines where to start the search. |
end | This is an optional parameter. It defines where to end the search. |
txt = "Welcome to PHPTPOINT."
x = txt.find("PHP")
print(x)
txt = "Welcome to PHPTPOINT"
x = txt.find("PHP",5,15)
print(x)
txt = "Welcome to PHPTPOINT"
x = txt.find("PHP",5,10)
print(x)