I have trouble understanding how this happens, keep in mind i'm very new to programming. let's say my char_list = ["a", "b", "a", "c", "a"] if i input "a" (as inp),index = [0, 0, 0], instead of [0, 2, 4]
def sub_letter(char_list, inp):
index = [char_list.index(x) for x in char_list if x == inp]
print(index)
Index is further used in the function but i haven't included it in the question in order to make it clearer.
Thank you to anyone who takes the time to answer!