# Apply Iteration On The Each Element In The Vector With A Time Delay

## 14 September 2019 - 1 answer

I have a vector having 8 elements , i want each element ot be itertated from initial state "30.9" and after every 1 second it is changed from 0 to 10 and soo on till 100 step by step , after it reach 100 then iteration moves to the second element "30.9" makes it 0 and then increase 10 value per second reaches highes to 100 and then back to initial condition.

``````hb =  [30.9, 30.9, 33.9, 41.6, 46.6, 54.4, 59.2, 65.6]
counter = 1
multiplier = 1
for i in range(1,9):
Application.Variables['P():///Constant'+str(i)+'/Value'].ValueConverted = hb[counter]
multiplier = multiplier + 1
counter = counter + 1
``````

My attempt using the time module and a nested for loop. The time module allows you to use time.sleep(), which will wait for a specified number of seconds. I also changed the range from 1,11, since that will allow for 10 iterations, as range iterates from the starting element to the end element-1.

``````import time
hb =  [30.9, 30.9, 33.9, 41.6, 46.6, 54.4, 59.2, 65.6]
counter = 1
multiplier = 1
for element in hb:
print("Currently processing element: ", element)
#Reset counter and multiplier after each loop
counter = 1
multiplier =1
for i in range(1,11):
#Do processing here
multiplier = multiplier + 1
counter = counter + 1
time.sleep(1)
``````

Here is a screenshot of the program in progress: