def trouveOuDitOuInserer(sequence, val, inf=0, sup=None): if sup is None: sup = len(sequence)-1 if sup < inf : return inf mid = (inf + sup) // 2 if sequence[mid] == val: return mid if sequence[mid] < val: inf = mid + 1 else: sup = mid-1 return trouveOuDitOuInserer(sequence, val, inf, sup) 3 ary = (2, 3, 4, 6, 7,9,10, 12, 13) print('On cherche dans ', ary, ' et les places sont : ') print('7 ', trouveOuDitOuInserer(ary, 7, 0, len(ary) -1));input('?'); print('2 ',trouveOuDitOuInserer(ary, 2, 0, len(ary) -1));input('?') print('5 ',trouveOuDitOuInserer(ary, 5, 0, len(ary) -1));input('?') print('15', trouveOuDitOuInserer(ary, 15, 0, len(ary) -1));input('?') print('1', trouveOuDitOuInserer(ary, 1, 0, len(ary) -1));input('?') """ tests On cherche dans (2, 3, 4, 6, 7, 9, 10, 12, 13) et les places sont : 7 4 2 0 5 3 15 9 1 0 """