Created Variables and passing another variable into it

Hello All,

I have created multiple variable like Q1,Q2,Q3,Q4,Q5 … etc. I need to make it inside of loop and pass another variable into it. For ex :

Count=1
While loop {
Q+count.tostring
Count = Count+1
}

output showing like 1,2,3… but i need it like Q1, Q2… ( The real concept is already i created it as variable its value is Q1=“Srini”. So i need the output like Srini )

Please guide me

@srinivasanma1

you want the output as Q1,Q2

you use like this inside the while loop

“Q”+count.tostring

Yes i did try it, but getting like Q1. The real concept is already i created it as variable its value is Q1=“Srini”. So i need the output like Srini

You should be using an array. With it you can do a FOr each indexing the array and printing all positions one by one

@srinivasanma1

i think you want to display the values which are stored in the variables is it right

but how you can call the values which are stored in that variables named as Q1,Q2,…

You can’t. There is no way to use an expression to represent a variable name. You should be using a dictionary (of string, string). You dictionary will look like:

{
“Q1”:“Srini”,
“Q2”:“Value2”,
“Q3”:“Value3”,
etc.}

Then you can reference the values with yourDictVarName(“Q1”) which will return the string Srini

1 Like