I want this function to return the position of each occurrence of a specific character in a given string without using the find function.
The code only returns the first instance, but not the rest of them. I could use append, but I'm not sure on how to use it. This is what I've tried so far:
#eg: find("Pythhon","h")
#needed output: [3,4] (the positions of each occurrence)
#instead the output is showing: [3] (position)
def find(string, token):
#start at index 0
for e in range(0,len(string)):
#compare each character to token
if string[e] == token:
#if true return the position of occurences
return [e]