FAQ: Linear Search: Conceptual - Linear Search

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

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

Search Algorithms

FAQs on the exercise Linear Search

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!

@mtf, There is an error. In this cheat sheet:
https://www.codecademy.com/learn/search-algorithms/modules/linear-binary-search/cheatsheet
, I saw Javascript.
This is a Python Course, this forum topic was linked to a python course and there is Javascript:

function binarySearchRecursive(array, first, last, target) {
  let middle = (first + last) / 2;
  // Base case implementation will be in here.
  
  if (target < array[middle]) {
    return binarySearchRecursive(array, first, middle, target);  
  } else {
    return binarySearchRecursive(array, middle, last, target);
  }
}

The reason I know it is Javascript is because I’ve learnt a bit(very little) of it ago but I wanted to exit Javascript(about more than 8 months ago).
But there’s Python also(expected):

def linear_search(lst, match):
  for idx in range(len(lst)):
    if lst[idx] == match:
      return idx
    else:
      raise ValueError("{0} not in list".format(match))
 
recipe = ["nori", "tuna", "soy sauce", "sushi rice"]
ingredient = "avocado"
try:
  print(linear_search(recipe, ingredient))
except ValueError as msg:
  print("{0}".format(msg))

Might be it is the only cheat sheet at hand. Follow the values and logic. Regardless the language, it will make sense.

It does make sense but why didn’t people report this mistake(it’s obvious)?

Beats me. I’m only one of the chickens.

Oh no, I have to search this up on what it means on here: Home | The Canadian Encyclopedia
:

Not Canadian. But maybe this side of the pond.


In these parts it means we’re not the boss, just digging the ditches.

I am going to ask you are formatting question. How do you write a post that has the arrows that you click and then something(or code) pops up? How do you write a post that has text that seems like it’s hidden by a shade.

[details="title"]  // show/hide detail
[spoiler]          // blur
<pre>```python     // 3 backticks and language
    code
</pre>```
[/spoiler]
[/details]

Let me try:

Python
 ``` python
       # Simplest Python code I can imagine:
       print(1)
```

Why do the pre tags look a bit like HTML tags? I think there is an indentation mistake. Is there any more tags that are like <pre> or tags like [details = "something"]

What is //?

The pre tags are HTML. Normally we only use three backticks but they disappear. I used the tags so we can see the backticks.

// is a mistake. Should be # for Python comments.

This FAQ seems to be miscategorized so I’m going to fix that.

In this course the FAQ’s are always miscategorized(except this one). Why couldn’t I change it to the Python FAQ? What language uses ``//` for comments?

JavaScript, Java, C, PHP, to name a few.

How do you know, I thought you didn’t know C, PHP, Java? Did you search it up? How many languages do you actually are familiar with? In your top categories thing I see:
Python, JavaScript, CSS. Do you know HTML?

C and Java are languages that I recognize, but don’t use myself. JavaScript, PHP, CSS, HTML are all familiar languages in the sense I’ve used them all in the past when I had a handful of websites. I learned more about them once I joined CC (previous I knew enough to solve my own dev problems) and scratched the surface with C and Java. Python and Ruby, also.

Recall, that I am retired and this is now a simple hobby.

So what are all the languages that you remember that you have used in your whole life?

Back in the seventies and eighties it was BASIC, and I dabbled with Pascal, but only the same way I dabble with Python. I knew many flavors of BASIC going back to Integer Basic (Timex and early Apple), Applesoft Basic, Vic/Commodore Basic, Atari Basic, Tandy Computer Basic, Microsoft Basic for MacIntosh, TRS Basic (CoCo 1, 2 & 3), BasicO9 (CoCo3 & OS-9), and QBasic (MS-DOS).

I scratched the surface with Assembly language, but only for the purpose of faster math operations. BASIC in most forms had a USR command that would switch into assembler mode, do its stuff, then restore BASIC again. The assembly language was not that different between the processors of the day. They had their own instruction set, but most of them were common as far as I got.

My efforts to learn C and Java were in vain, I’m afraid, but I still have books (which cost a fortune in the day).

All of that is a distant memory now. It was in the 90’s that I learned Hypercard on the Mac when I went back to complete my high school. When the web emerged, HTML appeared on the scene and was a breeze to get into since they are basically the same thing, just on a different medium. In about 2000 I jumped headlong into developing static websites for some local non-profits and it grew from there. CSS and HTML were the only languages I used for years. It wasn’t until around 2004 or 5 that I began to write JavaScript for things like e-mail address obfuscation, form validation, and the likes. Eventually I took up PHP so I could make my sites more dynamic. None of those sites are up, today, but a few of them had some pretty impressive code, server side (at least to me).

With the emergence of Windows 3.11 I took an interest in the Registry and spent more time dabbling with that that any programming languages. Tweaked a lot of 386, 486 and 586 boxes to give their owners some bells and whistles. I was pretty good at MS-DOS so wrote a lot of batch files, in the day, too. That, too, is now a distant memory. I’ve been running native Windows machines for the past several years and never touch the registry, anymore. Out of the box has been my user mode for everything since post-Windows 98. It was with the release of Windows XP that I switched to web development and quit working on people’s computers.