While applying Binary Search, could someone please explain: In Section 6, why this strategy works “If the middle element of the list is smaller than the last element of the range, then the answer lies to the right of it. Otherwise, the answer lies to the left.” when in the examples given in this section don’t align with this statement.

As far as Binary Search goes, I do get the basic idea on how to proceed but if this statement is a mistake like you pointed, should we be thinking in completely opposite direction to this statement. Also, in the function definition, please correct me if I’m wrong here, shouldn’t we interchange the lines of code under elif and else given what is mentioned in the comments?

I get that we can change anything in the code and the notebook but that was not what I wanted to know. Anyways, thank you again for your time and inputs.
Cheers

If the middle element of the list is smaller than the last element of the range, then the answer lies to the right of it. Otherwise, the answer lies to the left.
what does it mean?

As per this statement, if we take an example with this list: [7, 8, 1, 3, 4, 5, 6]. Middle element is 3 which is smaller than last element of the range which is 6. So, the answer lies to the right of it (middle element: 3) but here it lies on the left (1). This is puzzling for me as well but I got a reply above mentioning that this is a mistake. I’m not sure what I’m missing here, or if my understanding is completely wrong.

Yes, opposite is right. The statement should have been ''If the middle element of the list is smaller than the last element of the list then the answer lies to the left of it (middle element). Otherwise, the answer lies to the right.

@ankitparashar88 You can change the code with caution from the instructor that do not delete any cells, but you can add them. You should his variable names the same but feel free to add your own. He does have scripts for evaluation.

For example, in the list [6, 7, 1, 2, 3, 4, 5] the middle element is 2 and the last element is 5. 2 is smaller than 5, and the answer - that is, the only element smaller than the element before it - lies to the left of the middle element: [6, 7, 1, 2, 3, 4, 5] However in the list [4, 5, 6, 7, 1, 2, 3], the middle element is 7 and the last element is 3. 7 is greater than 3, and the answer lies to the right of the middle element: [4, 5, 6, 7, 1, 2, 3]
Hope this helps!