def contains(x, quarry): """prec: x is a list postc: returns True if quarry is present in the list.""" for item in x: if item == quarry: return True return False def contains_sorted(x, quarry): """ prec: x is a sorted list of sortable items (homogeneous) postc: return True if quarray is present.""" if len(x) == 0: return False if len(x) == 1: return x[0] == quarry n = len(x) // 2 if x[n] == quarry: return True if x[n] < quarry: return contains_sorted(x[n:], quarry) else: return contains_sorted(x[:n], quarry) x = list(range(2, 200, 7)) print(contains_sorted(x, 49)) print(contains_sorted(x, 51))