How do I print a variable value outside to for loop

My test is to execute for loop for twenty times and I have created a variable called “iteration” to store the value, each time my variable value will change. So I would like to do the following:

At each iteration my variable name should change from iteration to iteration 1, iteration 2….20.

Any way each time its storing the different value

I want to print all twenty variable outside the loop with different value.

Please suggest me how I can achieve this.

for (int I= 0; i<=20; I++)


Step 1


Step 3

iteration = “tame taken to execute”

Print (iteration)


I wanna change the value of my variable iteration plus loop and print each value outside of for loop.

Thanks in advance Satish :slight_smile:

will be use of array or list an solution for you?

Thanks @Andrej for replay anything fine for me but it should print outside the loop.

def iteration = []

for (i = 1; i <= 5; i++ ){

println "iteration as array: $iteration"

println "iteration by elements: iteration[0], iteration[1], iteration[2], iteration[3], iteration[4] -> ${iteration[0]}, ${iteration[1]}, ${iteration[2]}, ${iteration[3]}, ${iteration[4]}"

this is what you need to read :

Thanks its working for me and my problem got resolve.