I need to write a code that Given a list of numbers return a list in which all equal adjacent elements have been reduced to a single element. example: list=[1,1,3,4,5,5,6,7,7,7,8,5,7] becomes [1,3,4,5,6,7,8,5,7]
i wrote this code:
list = []
list1 = []
for i in range(10):
c = input("inserisci un numero: ")
list.append(c)
k = 0
for i in range(len(list)-1):
if list[i+1] != list[i]:
list1[k].append(list[i])
k+=1
print(list1)
ut it's giving me index error could you explain me why?