You have probably redefined your function "sum" as an integer data type. Therefore, it is fair to tell you that an integer is not something that you can convey to a range.
To fix this, restart your interpreter.
Python 2.7.3 (default, Apr 20 2012, 22:44:07) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> data1 = range(0, 1000, 3) >>> data2 = range(0, 1000, 5) >>> data3 = list(set(data1 + data2)) # makes new list without duplicates >>> total = sum(data3) # calculate sum of data3 list elements >>> print total 233168
If you obscure the built-in sum
, you may get the error message that you see
>>> sum = 0 >>> total = sum(data3) # calculate sum of data3 list elements Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not callable
Also note that sum
works fine on set
, there is no need to convert it to list
source share