2020-08-14

Python - Ignore the first copy/duplicate of the highest value in a list

l = [1,2,3,4,4,5,5,5,6,1,6]

duplicates = list(set(

    [

        

        for x in l 

        if l.count(x) > 1 

            and x == max(l)

    ]

))

for d in duplicates:

l.remove(d)

print(l)

No comments:

Post a Comment