I'm new to Python and i'm trying to remove duplicates from a simple list by using list comprehension (without using sets).
a = [1, 1, 2, 2, 2, 3, 5, 8, 13, 21, 34, 55, 89]
i can do it by doing this:
z=[]
for x in a:
if(z.count(x)==0):
z.append(x)
but with using list comprehension i don't know why it doesn't work:
z=[]
z=[x for x in a if z.count(x)==0]
what's the error there ?