import re
from collections import Counter
words = re.findall('\w+', open('/Users/Jack/Desktop/testytext').read().lower())
listy = Counter(words).most_common()
theNewList = list(listy)
theNewList[1][1] = 10
#****ERROR HERE****
#Traceback (most recent call last):
# File "countTheWords.py", line 16, in <module>
# theNewList[1][1] = 10
#TypeError: 'tuple' object does not support item assignment
在我看來,list()調用應該將'listy'轉換爲列表。任何想法我做錯了什麼?將元組轉換爲列表
和「listy的價值'究竟是什麼?我們應該猜測它嗎? –