From 949a29df4f30101bda07a9deb309f424a391c584 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sun, 5 Jan 2020 14:39:06 +0200 Subject: [PATCH] Update filter_non_unique.md --- snippets/filter_non_unique.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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