# FAQ: Binary Search: Python - Recursive Binary Search: Base Case 2

This community-built FAQ covers the “Recursive Binary Search: Base Case 2” exercise from the lesson “Binary Search: Python”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## FAQs on the exercise Recursive Binary Search: Base Case 2

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

What’s wrong with this code:

# define binary_search() def binary_search(sorted_list, target): if not sorted_list: return 'value not found' mid_idx = len(sorted_list)//2 mid_val = sorted_list[mid_idx] elif mid_val == target: return mid_idx # For testing: sorted_values = [13, 14, 15, 16, 17] print(binary_search([], 42)) print(binary_search(sorted_values, 42)) print(binary_search(sorted_values, 15))

?
But this code works:

# define binary_search() def binary_search(sorted_list, target): if not sorted_list: return 'value not found' mid_idx = len(sorted_list)//2 mid_val = sorted_list[mid_idx] if mid_val == target: return mid_idx # For testing: sorted_values = [13, 14, 15, 16, 17] print(binary_search([], 42)) print(binary_search(sorted_values, 42)) print(binary_search(sorted_values, 15))

Maybe it’s because to use `if` then `elif` that correspond to each other, I have to put them together? Maybe because I used `return` in the `if. I don’t have that much experience in these things.