0
我寫了這個功能:使用lambda功能和字典顯示功能,可以用不同的方式
def make_upper(words):
for word in words:
ind = words.index(word)
words[ind] = word.upper()
但我需要使用哪個我不熟悉lambda函數寫。有任何想法嗎?
我還寫道,計算每個字母出現的頻率的函數:
def letter_cnt(word,freq):
for let in word:
if let == 'A': freq[0]+=1
elif let == 'B': freq[1]+=1
elif let == 'C': freq[2]+=1
elif let == 'D': freq[3]+=1
elif let == 'E': freq[4]+=1
所以我需要用字典來寫。有什麼建議麼?