I am trying to solve this question "Good array is the array that does not contain any equal adjacent elements. Given an integer array A of length N, you are asked to do some operations (possibly zero) to make the array good. One operation is to remove two equal adjacent elements and concatenate the rest of the array. A : (1, 2, 2, 3, 4) An after-one operation : (1, 3, 4) " With python list, as follow:
L=[]
n=int(input("Enter a num"))
for _ in range(n):
x=int(input())
L.append(x)
print(L)
for z in range(L):
if L[z]==L[z+1]:
L.remove(z)
L.remove(z+1)
print(L)
I keep getting this error: Input In [37] if L[z]==L[z+1] ^ SyntaxError: invalid syntax any solutions!!`