def code_msg(msg, code):
    """
    Function that codes a given text with a given Huffman code for each character.
    :param msg:
    :param code:
    :return: coded_msg
    """
    coded_msg = ""
    for char in msg:
        coded_msg += code[char]
    return coded_msg