If you want to find all matches, you'll need some form of repetition (iterative loop or recursion).
Judging by the signature of your function your intention was to use recursion, which would look like:
def matchall_version1(theList, value, i=0):
try:
i = theList.index(value, i)
yield i
yield from matchall_version1(theList, value, i+1)
except ValueError:
pass
And using a loop your code would look like:
def matchall_version2(theList, value):
i = 0
try:
while True:
i = theList.index(value, i + 1)
yield i
except ValueError:
pass
However I'd like to suggest this other version, which is far more readable than yours imho:
def matchall_version3(theList, value):
for i, x in enumerate(theList):
if x == value:
yield i
All three versions yield to the same result. This:
theList = ['a','e','i','o','u','e','o','e']
print(list(matchall_version1(theList, 'e')))
print(list(matchall_version2(theList, 'e')))
print(list(matchall_version3(theList, 'e')))
Prints this:
[1, 5, 7]
[1, 5, 7]
[1, 5, 7]