Use list of integer type in a loop in python

DDPT is an array of integers, as evidenced in this line:

DDPT = [int(round(pt*TCV)) for pt in [.3,.5,.2]]

DDPT[PT] is some integer, and you are trying to iterate through that. Hence the error.

I would recommend giving your variables more descriptive names so these issues are easier to debug.

edit:

for num_iters in DDPT:
for iteration in range(num_iters):
do_something()

Browse More Popular Posts

Leave a Comment