TonyKutunio
TonyKutunio

Reputation: 3

TypeError: 'list' object is not callable. sum() function

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

Answers (1)

Petru Tanas
Petru Tanas

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

Related Questions