0
sum = 0 
my_sum = sum([i*2 for i in range(2, 196)])  

I have an TypeError: int object is not callable for the code above.

What I am doing wrong?

The code before was like that:

sum = 0
for i in range(2, 196):
    sum = sum + i
 print(sum)

I am trying to sum up the squares of the integers instead of just the integers.

Sydney_dev
  • 1,448
  • 2
  • 17
  • 24

1 Answers1

0

Assuming this is python and I believe it's because you are trying to use the sum function with a declared variable named 'sum' equal to 0 (which defaults to 'int'), you cannot declare a variable with the same name as the built-in function, it overrides it with the variable in the program.

refer to: TypeError: 'int' object is not callable

r_mchugh
  • 3
  • 4