From 87f3d7bb54cf2c546bde694b14c5e588fc3e7dbc Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 6 Oct 2013 12:36:39 +0200 Subject: Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on docs@. --- Doc/library/collections.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index a65fe5b..a47d99b 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -307,7 +307,7 @@ Common patterns for working with :class:`Counter` objects:: dict(c) # convert to a regular dictionary c.items() # convert to a list of (elem, cnt) pairs Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs - c.most_common()[:-n:-1] # n least common elements + c.most_common()[:-n-1:-1] # n least common elements +c # remove zero and negative counts Several mathematical operations are provided for combining :class:`Counter` -- cgit v0.12