<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def codes_get_string(handle, key, length=None):
 # type: (cffi.FFI.CData, str, int) -> str """ Get string element from a key. It may or may not fail in case there are more than one key in a message. Outputs the last element. :param bytes key: the keyword to select the value of :param bool strict: flag to select if the method should fail in case of more than one key in single message :rtype: bytes """

    if length is None:
        length = codes_get_string_length(handle, key)
    values = ffi.new('char[]', length)
    length_p = ffi.new('size_t *', length)
    _codes_get_string = check_return(lib.codes_get_string)
    _codes_get_string(handle, key.encode(ENC), values, length_p)
    return ffi.string(values, length_p[0]).decode(ENC)