Sum function for lists

n=1000
k=list(range(n))
sum_=sum(k)
print(sum)

Instead of getting the sum of the values in the list, I am surprisingly getting an error stating ‘int’ object is not callable.

Try printing sum_ instead of sum in last line. Also make sure to execute or rerun statements in correct order (if codes are in different cells) to further resolve the error.

image

1 Like

Thank you so much. Can’t believe I didn’t notice that one.

1 Like