Average word

定义一个变量,它的值等于input ()输入的字符串,然后统计输入的字符串所包含的字符数量。并且用统计的字符总数量除以字符串中单词的个数,求出每个单词所占有的字符数的平均值。比如变量的输入值是"hi nice to meet you",不算空格有15个字母,那么5个单词每个单词所占的字符平均数为15/5=3,请问这个过程怎样实现呢?

# -*- coding: cp936 -*-
word = ''
while len(word) <= 0:
    word = input('请输入字符串:')
arr = word.split(" ")
total = 0
for ii in range(len(arr)):
    total = total + len(arr[ii])
print "每个单词所占有的字符数的平均值: " + str(total/len(arr))

img