How to eliminate duplicates in a list preserving previous order    
   Ex: if A=[1,5,3,3,4,9,9,9,1] I want to obtain [1,5,3,4,9,1] in a simple way
For example via list comprehension:
B = [A[i] for i in range(len(A)) if i==0 or A[i]!=A[i-1]]
 Asked: 2022-10-26 11:05:53 +0100
Seen: 509 times
Last updated: Oct 26 '22
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.