Skip to content

Commit 87f3d7b

Browse files
committed
Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on docs@.
1 parent f27bfd8 commit 87f3d7b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doc/library/collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Common patterns for working with :class:`Counter` objects::
307307
dict(c) # convert to a regular dictionary
308308
c.items() # convert to a list of (elem, cnt) pairs
309309
Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs
310-
c.most_common()[:-n:-1] # n least common elements
310+
c.most_common()[:-n-1:-1] # n least common elements
311311
+c # remove zero and negative counts
312312

313313
Several mathematical operations are provided for combining :class:`Counter`

0 commit comments

Comments
 (0)