简体   繁体   中英

How to fix the error :'range' object is not callable in python3.6

my code looks like:

list_var = ['rh','temp','tl','Tt','DPD','PAR']
for L in range(1, len(list_var)):
     for subset in itertools.combinations(list_var, L):
          f = 'inf ~ {} + C(area)'.format(' * '.join(list(subset)))

error 'range' object is not callable jumped up even I changed len(list_var) into a number. Can you identify the problem and fix it? Thank you in advance!!!

I can reproduce the issue when assigning the range name to a range instanciated object:

>>> range = range(10)
>>> range(1)
Traceback (most recent call last):
  File "<string>", line 301, in runcode
  File "<interactive input>", line 1, in <module>
TypeError: 'range' object is not callable

you probably reassigned the name earlier in your code, triggering this exact error.

A quick & dirty fix is:

del range

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM