Maybe it's too simple and I just didn't see my mistake.
while list_a[y] in list_a != list_a[-1]:
print(y);y=y+1
returns IndexError: list index out of range
list_a looks like:
['00001', '00001', '00002', '00009', '0000G', '0000K', '0000K', '0000U', '0000U', '00013', '0001B', '0001D', '0001D', '0001L', '0001L', '0001N', '0001Q', '0001Q', '0001R', '0001U']
and my aim in the end is to delete some items from the list while iterating (that's why I want to use a while loop instead of for y in range(len(list_a))).
list_a[y]is inlist_a(either true or indexerror) and then compares that (true) tolist_a[-1]. Probably not what you wanted. Have you tried just usingwhile y < len(list_a)?inand!=have the same precedence, sox in y != zactually evaluates like(x in y) and (y != z), similar tox < y < z.)