]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix argument order in multinomial() example (gh-132557)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 15 Apr 2025 16:50:52 +0000 (11:50 -0500)
committerGitHub <noreply@github.com>
Tue, 15 Apr 2025 16:50:52 +0000 (11:50 -0500)
Doc/library/itertools.rst

index 61e413b63cdfbebb42109d15a2fe4b20901b02cd..438f3db60c396d689a835612fadabd6e8b662b8e 100644 (file)
@@ -1129,8 +1129,8 @@ The following recipes have a more mathematical flavor:
 
    def multinomial(*counts):
        "Number of distinct arrangements of a multiset."
-       # Counter('abracadabra').values() -> 5 2 1 1 2
-       # multinomial(5, 2, 1, 1, 2) → 83160
+       # Counter('abracadabra').values() → 5 2 2 1 1
+       # multinomial(5, 2, 2, 1, 1) → 83160
        return prod(map(comb, accumulate(counts), counts))
 
 
@@ -1736,7 +1736,7 @@ The following recipes have a more mathematical flavor:
     >>> ''.join(it)
     'DEF1'
 
-    >>> multinomial(5, 2, 1, 1, 2)
+    >>> multinomial(5, 2, 2, 1, 1)
     83160
     >>> word = 'coffee'
     >>> multinomial(*Counter(word).values()) == len(set(permutations(word)))