"The simplest search is to look at everything until you find it. It's not clever, and that's exactly the point — sometimes the unclever O(n) scan is genuinely the right answer, and over-engineering it is the mistake."
The Algorithm With Nothing to Hide
Linear search walks the collection one element at a time and stops when it finds the target (or reaches the end). It's O(n) worst case, O(1) best case (target is first), and it has one enormous virtue: it works on any collection, sorted or not, with zero setup. When data is unsorted and you have no index, linear search isn't a fallback — it's the only option, and an honest one.
The Over-Engineering Trap
Here's the judgment this lesson is really about. It's tempting, having learned about binary search and hash maps, to reach for them reflexively. But consider: to binary-search unsorted data you must sort it first — that's O(n log n), more expensive than a single O(n) scan. For a one-time search of unsorted data, linear search wins outright. The fancy structures only pay off when their setup cost is amortized over many searches. Reaching for binary search on data you'll query once is the classic premature optimization — you paid n log n to save on a single n.
The Pythonic Forms
You rarely write the loop by hand — Python gives you linear search in expressive forms: x in items (is it present?), items.index(x) (where is it?), any(pred(x) for x in items) (does any match a condition?), and next((x for x in items if pred(x)), default) (the first match, or a default). All of them are O(n) scans under the hood. Knowing they're linear is what stops you from carelessly nesting one inside a loop and creating an accidental O(n²) — the trap from the Complexity track.