]> granicus.if.org Git - python/commitdiff
Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on docs@.
authorGeorg Brandl <georg@python.org>
Sun, 6 Oct 2013 10:36:39 +0000 (12:36 +0200)
committerGeorg Brandl <georg@python.org>
Sun, 6 Oct 2013 10:36:39 +0000 (12:36 +0200)
Doc/library/collections.rst

index b7628bb8deb72e2d1f29ff0a63f847f01e2c833a..838c507caecc7ce89872d1daa2077ad7a2e08b9e 100644 (file)
@@ -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`