Update filter_non_unique.md

This commit is contained in:
Angelos Chalaris
2020-01-05 14:39:06 +02:00
committed by GitHub
parent 23f68fee3a
commit 949a29df4f

View File

@ -5,15 +5,14 @@ tags: list,beginner
Filters out the non-unique values in a list.
Use `Counter` to get the count of each value in the list.
Use a `Counter` to get the count of each value in the list.
Use list comprehension to create a list containing only the unique values.
```py
from collections import Counter
def filter_non_unique(lst):
counter = Counter(lst)
return [item for item, count in counter.items() if count == 1]
return [item for item, count in counter = Counter(lst).items() if count == 1]
```
```py