From: Georg Brandl Date: Sun, 6 Oct 2013 10:36:39 +0000 (+0200) Subject: Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on docs@. X-Git-Tag: v2.7.6rc1~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97ea40aa6dd3838ed1bb6b34b34c367352792fb7;p=python Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on docs@. --- diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index b7628bb8de..838c507cae 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -146,7 +146,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 += Counter() # remove zero and negative counts Several mathematical operations are provided for combining :class:`Counter`