+3 votes
in Programming Languages by (19.3k 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

0 votes
by (33.7k points)

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.

...