FAQ: Linear Search: Python - Review

This community-built FAQ covers the “Review” exercise from the lesson “Linear Search: Python”.

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

Search Algorithms

FAQs on the exercise Review

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 (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.

Ask or answer a question about this exercise by clicking reply (reply) below!

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

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

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!

In the linear search lesson where finding duplicates, codecademy turned the exercises green, when it actually gave me an error, and in the review I tried using the same solution, but it still wont give me right answer and I tried to move the line matches.append[idx] to different places, and then it gave me a ValueError, saying soy sauce is not in the list. Can anyone tell me why is that, or how can I make this work??

And also noting that this isn’t the first time something like this has happened. Codecademy often tells me the answer is right, when it actually doesn’t do the work, or raises an Error. Why is that? I’m feeling that I can’t really learn that way…

I had some issues with the Linear Search exercises myself as in one case, the code provided by the exercise at the start will throw an error. On 3/6, you have to delete or comment out the try/except blocks until actually asked to use them, or the code will break and you cannot complete step 1.

I don’t have an answer for why CA sometimes accepts answers that are throwing errors, but looks to me like the problem with your code is that you’re appending all the indexes to the matches list without having an if check on whether they’re actually the thing you’re looking for. If you stick an “if search_list[idx] == target_value:” before your matches.append command and move the other if statement outside the for loop, it should work.