diff --git a/snippets/filter_non_unique.md b/snippets/filter_non_unique.md index 6563285a0..373d1edbc 100644 --- a/snippets/filter_non_unique.md +++ b/snippets/filter_non_unique.md @@ -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