res = [3, 1, 1, 5, 2, 4, 2, 4, 2, 4, 3, 1, 1, 5, 3]
while not i>(len(res)-1):
if res[i]==res[i+1]:
answer+=2
i+=2
else:
i+=1
The variable "answer" is supposed to count duplicated numbers that are placed next to each other. For some reason, I get the error saying IndexError: list index out of range. How do I fix this?