PythonStringfind

Returns the index of the first occurrence of a substring (-1 if not found).

Syntax

str.find(sub, start?, end?)

Example

Enter values below to update the example in real time.

print
find
text = "Hello World"
print(text.find("World"))   # 6
print(text.find("Python"))  # -1