def encode_sequence(sequence: str, encoding_scheme: dict):
    """
    Encodes a peptide sequence with values provided by the encoding table/scheme.
    """
    encoded_sequence = []
    for aa in sequence:
        try:
            value = encoding_scheme.get(aa)
        except Exception as e:
            msg = f'{e}'
            raise KeyError(msg)
        encoded_sequence.append(value)
    return encoded_sequence