+3 votes
in Programming Languages by (73.8k points)

The following "for" loop is giving error. The variable impf_idx is a list. How can I fix the error.

Traceback (most recent call last):

  File imp_features.py", line 262, in <module>

    for i in range(10, 20, impf_idx):

TypeError: 'list' object cannot be interpreted as an integer

1 Answer

+1 vote
by (349k points)
selected by
 
Best answer

The variable impf_idx is a list and hence your code is giving error. The last parameter in range() should be an integer.

Change

 for i in range(10, 20, impf_idx):

to

 for i in range(10, 20, len(impf_idx)):

to fix the error.


...