Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a1e9c2

Browse files
authored
Fix error in docstrings in bisect module (GH-21422)
The docstrings for `bisect_right()` and `bisect_left()` contain sample code that has a bug: `a.insert(x)` should be `a.insert(i, x)`.
1 parent 344dce3 commit 6a1e9c2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/bisect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def bisect_right(a, x, lo=0, hi=None):
1616
"""Return the index where to insert item x in list a, assuming a is sorted.
1717
1818
The return value i is such that all e in a[:i] have e <= x, and all e in
19-
a[i:] have e > x. So if x already appears in the list, a.insert(x) will
19+
a[i:] have e > x. So if x already appears in the list, a.insert(i, x) will
2020
insert just after the rightmost x already there.
2121
2222
Optional args lo (default 0) and hi (default len(a)) bound the
@@ -51,7 +51,7 @@ def bisect_left(a, x, lo=0, hi=None):
5151
"""Return the index where to insert item x in list a, assuming a is sorted.
5252
5353
The return value i is such that all e in a[:i] have e < x, and all e in
54-
a[i:] have e >= x. So if x already appears in the list, a.insert(x) will
54+
a[i:] have e >= x. So if x already appears in the list, a.insert(i, x) will
5555
insert just before the leftmost x already there.
5656
5757
Optional args lo (default 0) and hi (default len(a)) bound the

0 commit comments

Comments
 (0)