Open this example in the interactive library
Source code
from bisect import bisect_left
values = [2, 4, 7, 9]
print(bisect_left(values, 6))Sample output
2

Find a sorted insertion point. A self-contained example using the Python standard library.
Open this example in the interactive library
from bisect import bisect_left
values = [2, 4, 7, 9]
print(bisect_left(values, 6))2