Reputation: 3
Can anyone explain why jupyter notebook says: "TypeError: 'list' object is not callable", When trying to execute the following code:
a = [3, 2, 6, 2, 2, 1, 4, 2, 2, 0, 3, 6, 7, 4, 6, 3]
b = sum(a)
print(b)
But PyCharm returns: 53
????
Upvotes: 0
Views: 1189
Reputation: 1247
Jupyter notebook allows you to run code line by line, which means that if you defined a variable called "sum" in one of the cells, and this variable has a list in it, the "sum" function is overwritten until you restart the kernel, and know only the variable exists, which cannot be called.
Upvotes: 1