def pattern_matching(pattern, genome):
    """Find all occurrences of a pattern in a string.

    Args:
        pattern (str): pattern string to search in the genome string.
        genome (str): search space for pattern.

    Returns:
        List, list of int, i.e. all starting positions in genome where pattern appears as a substring.

    Examples:
        Find all the starting positions for a pattern string in the genome string.
        
        1.

        >>> pattern = 'ATAT'
        >>> genome = 'GATATATGCATATACTT'
        >>> positions = pattern_matching(pattern, genome)
        >>> positions
            [1, 3, 9]

        2.

        >>> pattern = 'CTTGATCAT'
        >>> genome = 'CTTGATCATCTTGATCATCTTGATCAT'
        >>> positions = pattern_matching(pattern, genome)
        >>> positions
            [0, 9, 18]
    """
    positions = [] # output variable
    for i in range(len(genome)-len(pattern)+1):
        if genome[i:i+len(pattern)] == pattern:
            positions.append(i)
    return positions