<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _validate_charset(data, charset):
 """"Validate that the charset is correct and throw an error if it isn't."""

        if len(charset) > 1:
            charset_data_length = 0
            for symbol_charset in charset:
                if symbol_charset not in ('A', 'B', 'C'):
                    raise Code128.CharsetError
                charset_data_length += 2 if symbol_charset is 'C' else 1
            if charset_data_length != len(data):
                raise Code128.CharsetLengthError
        elif len(charset) == 1:
            if charset not in ('A', 'B', 'C'):
                raise Code128.CharsetError
        elif charset is not None:
            raise Code128.CharsetError