You declare a Boolean searching_for_a_0 = True, then iterate over the list. Inside the loop, you have if searching_for_a_0: if item == 0: searching_for_a_0 = False else: “”“ from the first if ”“” if item > S: result.append( item ) looking_for_a_0 = True, the solution of dividing the list into sublists involves iterating over the list to create the sublists, and then iterating over each of these, so it is not efficient.