Learn

Binary Search: Python

Recursive Binary Search: Base Case 2

We now have a base case for when we do not find the value in our sorted list, but we need a base case for when we DO find the value.

At this step, we have three options:

**BASE CASE:**`mid_val`

matches our`target`

**RECURSIVE STEP:**`mid_val`

is less than our target**RECURSIVE STEP:**`mid_val`

is more than our target

We’ll tackle the alternate base case first.

### Instructions

**1.**

Let’s complete the base case for when we have found the value.

After the declarations for `mid_val`

and `mid_idx`

, write a conditional that checks if `mid_val`

is our `target`

.

If it is, return `mid_idx`

.