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
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]]
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2022-10-26 11:05:53 +0100
Seen: 363 times
Last updated: Oct 26 '22
Can I define a function from a list of values?
iterating over a combinatorial class
Using @parallel in creating a list
Enumerate elements of a set built using properties
How to change the default program which open the 2D picture which the plot producted?
Substitute list of expressions