What is the Python 3 equivalent of find ()?
str = "Python"
In Python2:
string.find(str,"y")
In Python3:
str.find("y")
Isn't it still just find
? From the documentation:
str.find(sub[, start[, end]])
Return the lowest index in the string where substring sub is found, such that sub is contained in the slice s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found.
Use the .find()
method of a string, rather than string.find()
. (This also works, and is probably preferable, in python 2).