Contact: aviboots(AT)netvision.net.il
39,913 questions
51,846 answers
573 users
from bisect import bisect_left def binary_search(lst, n): i = bisect_left(lst, n) if i: return i - 1 else: return -1 lst = [1, 2, 3, 3, 4, 6, 20, 40] i = binary_search(lst, 7) if i == -1: print("Not found") else: print(lst[i]) ''' run: 6 '''