Examples for string find in Python
From the documentation:
str.find(sub[, start[, end]])
Return the lowest index in the string where substring sub is found within the slice
s[start:end]
. Optional arguments start and end are interpreted as in slice notation. Return-1
if sub is not found.
So, some examples:
>>> my_str = 'abcdefioshgoihgs sijsiojs '>>> my_str.find('a')0>>> my_str.find('g')10>>> my_str.find('s', 11)15>>> my_str.find('s', 15)15>>> my_str.find('s', 16)17>>> my_str.find('s', 11, 14)-1