Linear search is really simple: keep looking until we find the right item.
function is_the_one_we_want(item): # this would be a user-defined function that takes an item # and returns `True` if and only if this is the one we want, # and `False` otherwise False function find_item(): # we look through each item for item in list: # check if this item is the one if is_the_one_we_want(item): # return from this function, aborting the loop return Item # once we've gone through the list, if we haven't found the item # then it cannot be in the list return None

That's it!

The main problem with a linear search is that it is not very fast (compared to other search algorithms that we can use). This is because we have to look over every single item in the dataset – sometimes this is not too bad (if the data happens to be near where we start), but in the worst case we have to look over every item in the dataset.

The other search algorithm in the GSCE is a binary search which is more efficient, but can only be used when the data is sorted (whereas a linear search does not require this.)