strpos in python

203

strpos in python -

pos = haystack.find(needle)
pos = haystack.find(needle, offset)
#returns -1 when not found:

pos = haystack.index(needle)
pos = haystack.index(needle, offset)
#raises ValueError when not found:

#Also can be used to compare
if needle in haystack:

Comments

Submit
0 Comments