Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.


Linear Search Implementations


The implementation of linear search covered in the course is provided below.

def linear_search(lst, target):
    """Returns the index position of the target if found, else returns -1"""

    for i in range(0, len(lst)):
        if lst[i] == target:
            return i
    return -1

The code can be cleaned up a bit by using the enumerate function...