def count_pattern(pattern, lst):
    """
    count_pattern() returns the count of the number of times that the pattern occurs in the lst
    """
    count = 0
    if type(pattern) != type(lst):
        raise TypeError("count_pattern() : arguments must be of the same type")
    elif not pattern or not lst:
        return count
    else:

        # size of the pattern and the lst
        patternlength = len(pattern)
        lstlength = len(lst)

        # if the pattern is longer than the lst, quit out
        if patternlength > lstlength:
            return count

        # otherwise look for matches
        else:

            # for the maximum total possible matches
            for ii in range(lstlength - patternlength + 1):

                # step the pattern through the lst
                candidatematch = lst[ii:(ii + patternlength)]

                # if it's a match, increment the count of the matches
                if pattern == candidatematch:
                    count += 1
            return count