Python类型错误:int对象不可编辑

Python类型错误:int对象不可编辑,python,python-2.7,python-3.x,Python,Python 2.7,Python 3.x,我不确定从何处获得此错误: Traceback (most recent call last): File "C:/Users/Coscio/PycharmProjects/unigram/letterHist.py", line 78, in <module> main() File "C:/Users/Coscio/PycharmProjects/unigram/letterHist.py", line 74, in main bars(words)

我不确定从何处获得此错误:

Traceback (most recent call last):
  File "C:/Users/Coscio/PycharmProjects/unigram/letterHist.py", line 78, in <module>
    main()
  File "C:/Users/Coscio/PycharmProjects/unigram/letterHist.py", line 74, in main
    bars(words)
  File "C:/Users/Coscio/PycharmProjects/unigram/letterHist.py", line 62, in bars
    init(words, lst)
  File "C:/Users/Coscio/PycharmProjects/unigram/letterHist.py", line 38, in init
    freqLegend(words,val, lst)
  File "C:/Users/Coscio/PycharmProjects/unigram/letterHist.py", line 54, in freqLegend
    freqLegend(words, val/1.5,  counter-1)
  File "C:/Users/Coscio/PycharmProjects/unigram/letterHist.py", line 53, in freqLegend
    back((max(lst)*1000)/10)
TypeError: 'int' object is not iterable

您缺少
freqLegend
的一个参数,因此您得到了意想不到的行为。您只有三个参数:

freqLegend(words, val/1.5,  counter-1)
我想你的意思是什么

freqLegend(words, val/1.5, lst,  counter-1)
您之所以会得到一个不可编辑的错误,是因为
max()
实际上会遍历列表。由于参数
counter-1
作为参数
lst
传递给函数,因此在第二次调用
lst
时,它是一个int,无法迭代以找到最大值

freqLegend(words, val/1.5, lst,  counter-1)