python split 函數(shù) 入門問題
3 回答

揚帆大魚
TA貢獻1799條經(jīng)驗 獲得超9個贊
不應該是school么? 比例是0.333333333
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | def least_vowel_words(text): line=text.strip('.').split() wdict=dict() vowel='aeiouAEIOU' for word in line: num = 0.0 for chr in word: if chr in vowel: num+=1 r=str(float(num/len(word))) if r in wdict: wdict[r]=wdict[r]+[word] else: wdict[r]=[word] print wdict[min(wdict.keys())] |
添加回答
舉報
0/150
提交
取消