def split_n(seq, num):
    """Split |seq| in twain with the first part having length |num|."""
    if len(seq) < num:
        raise ValueError('sequence too short: seq={}, num={}'.format(seq, num))
    return seq[:num], seq[num:]