binary search
def binary_search(num, array): array = sorted(array) while True: value = False middle_index = int(len(array) / 2) if num == array[middle_index]: value = True break elif num > array[middle_index] and num <= array[-1]: array = array[middle_index:] elif num < array[middle_index] and num >= array[0]: array = array[:middle_index] else: break return value