I keep getting Index Errors when I try to use while loops in combination with lists.
I wrote the code some time ago, came back to it, but just couldn't wrap my head around it enough to find my mistake. Apparently, the error has something to do with my lists indexes being too small or too large.
indexes = []
#Or indexes[0], but this threw another error
indexes.append(decoded.find(special_string))
x=1
while indexes[x-1] > 0:
total = sum(indexes)
indexes[x] = decoded.find(special_string, total)
x+=1
print(indexes)
My goal is to find all substrings (special_string) in a string and get their indexes (please inform me if you know an easier way to do this). I want to write all indexes out into a list for further use.