I have a list and I want to get one element from two similar consecutive elements. (sort or if is not in new_list doesn't work as I want to keep those similar elements that are not consecutive)
I've written this, but it returns an error with the range function that [i+1] is not in the range:
like: input: ['a','b','b','c','c','a'] output: ['a','b','c','a']
list = ['a','b','b','c','c','a']
new_list = []
for i in range(0,len(list)+1):
if list[i]!=list[i+1]:
new_list.append(char[i])
i=i+1
print (new_list)