pass a variable to a table

Hi

I have  tables  called group1 ,2, 3 etc 

group1 = {1, 14, 27, 40} 

group2 = {2, 15, 28, 41} 

to look up a value this works fine

myAnswer = 27

if (group1[3] == myAnswer) then – = 27 so do something

but if I use a variable  to increment the group number like this it does not work

groupCount = 3

p1 =  “group”…groupCount…"[3]" --what is the same as group1[3]

if (p1 == myAnswer) then – = 27 so do something

I understand I am returning a string, what do I need to do?

Thanks

group = {}

group[1] = {1, 14, 27, 40}

group[2] = {2, 15, 28, 41}

Should probably allow you to solve the problem - use main group table , then sub tables.

T

Thanks I knew there would be a better way, but how do I then lookup the sub tables within group?

Basically each sub table has unique values and I need to now what key the value is in. So if I am looking for 27 I need to know if it is in group1, or group2 etc?

layered loops

one loop hanndles the rotation of group[a]

then within that loop another loop handling the items within the sub group group[a][b]

T.

group = {}

group[1] = {1, 14, 27, 40}

group[2] = {2, 15, 28, 41}

Should probably allow you to solve the problem - use main group table , then sub tables.

T

Thanks I knew there would be a better way, but how do I then lookup the sub tables within group?

Basically each sub table has unique values and I need to now what key the value is in. So if I am looking for 27 I need to know if it is in group1, or group2 etc?

layered loops

one loop hanndles the rotation of group[a]

then within that loop another loop handling the items within the sub group group[a][b]

T.