I know that .index() will return where a substring is located in python.
However, what I want is to find where a substring is located for the nth time, which would work like this:
>> s = 'abcdefacbdea'
>> s.index('a')
0
>> s.nindex('a', 1)
6
>>s.nindex('a', 2)
11
Is there a way to do this in python?
How about…
Obs: as
str.index()does,nindex()raisesValueErrorwhen the substr is not found.