為什么提示TypeError: 'int' object is not callable?
代碼:
sum = 0
n = 0
L = []
while n < 100:
? ? n = n + 1
? ? L.append(n*n)
print sum(L)
錯誤提示:
Traceback?(most?recent?call?last): ??File?"index.py",?line?7,?in? ????print?sum(L) TypeError:?'int'?object?is?not?callable
2019-04-23
把第一行的"sum=0"去掉,你在第一行聲明了一個"sum"變量,然后又在下面調用的"sum()"函數,兩個名稱沖突了