(Repost for clarity) This function returns the list with the positions of the codes when I put my mouse over the return lst: [1, 4, 7] (as its supposed to) but when I call the function it gives me the error builtins.ValueError: 'CB7' is not in list
I realize that the problem is in [i:].index(single_code) + i
How do I fix it without using enumerate() and list
comprehensions?
Here is my code:
sp_codes = ['EB9', 'CB7', 'EB9', 'N4Y', 'CB7', '4B9', '9OP', 'CB7', '4B9']
return lst
'''
testing code
'''
single_code = input('Enter a code: ') #Enter 'CB7'
pos_list = find_indexes(sp_codes, single_code)
print(pos_list) # ---> Prints [1, 4, 7]