<doocs>1592.Rearrange Spaces Between Words_1.py
def reorderSpaces( text: str) -> str:
    cnt = text.count(' ')
    words = text.split()
    m = len(words) - 1
    if m == 0:
        return words[0] + ' ' * cnt
    return (' ' * (cnt // m)).join(words) + ' ' * (cnt % m)
def sample_funcname ( var_0 : str ) -> str :
    var_4 = var_0.count ( ' ' )
    var_6 = var_0.split ( )
    var_9 = len ( var_6 ) - 1
    if var_9 == 0 :
        return var_6 [ 0 ] + ' ' * var_4
    return ( ' ' * ( var_4 // var_9 ) ).join ( var_6 ) + ' ' * ( var_4 % var_9 )
