ReferenceString methods
str.find()
The index of the first match, or -1 when there is none.
Signature
text.find(sub, start=0, end=len(text))Parameters
| Name | Means |
|---|---|
sub | what to look for |
start | where to begin |
end | where to stop |
Returns
An int, or -1.
Example
Python
line = "one,two,one"
print(line.find("two"))
print(line.find("three"))
print(line.rfind("one"))Output
4 -1 8