def encode ( strs ) : res = '' for string in strs . split ( ) : res += str ( len ( string ) ) + ":" + string return res
python wrap list to string length
Encodes a list of strings to a single string . : type strs : List [ str ] : rtype : str
def encode(strs):
    """Encodes a list of strings to a single string.
    :type strs: List[str]
    :rtype: str
    """
    res = ''
    for string in strs.split():
        res += str(len(string)) + ":" + string
    return res