I wrote the Python implementation for the this:
def alloccurences(ls, start, key):
if start == len(ls) - 1 and ls[start] != key:
return
if ls[start] == key:
print(start, "-->", key)
alloccurences(ls, start+1, key)
It prints the occurrences and also gives index out of bound error. for this input
ls = [1,2,3,4,5,20,20]
start = 0
key = 20
Can you correct the above code pls