def binaryToCounts(number, length):
    """
    Convert the last elements of a binary list to the corresponding photon
    decimal number and remove these elements from the list. Both the number
    and the new list are returned.

    ==========  ===============================================================
    Input       Meaning
    ----------  ---------------------------------------------------------------
    number      List of 0's and 1's.
    length      Integer number representing the number of bits that make up the
                last photon count number in the list.
    ==========  ===============================================================

    ==========  ===============================================================
    Output      Meaning
    ----------  ---------------------------------------------------------------
    counts      Decimal representation of the binary string of length 'length',
                formed by the last elements in the list.
    number      New binary list with the last 'length' elements removed.
    ==========  ===============================================================

    =======
    Example
    =======

    binaryToCounts(['1', '0', '1', '1'], 3) will return (3, ['1']).
    3: the decimal representation of the last elements in the list (0,1,1)
    ['1']: list with the remaining elements of the original list
    """

    counts = int(''.join(number[-length:]), 2)
    del number[-length:]
    return counts, number