Avoid problem with iterator?

Hello,
I am trying to get {Subscript[a, 0], Subscript[a, 1], Subscript[a, x], Subscript[a, x+1]} using the table as follows,

Table[Subscript[a, p], {p, {0, 1, x, x + 1}}  ]

But it does not return the last value of p.

This is the output: `{Subscript[a, 0], Subscript[a, 1], Subscript[a, x], 1}

Any help?
Thank you`

What version are you using? It works ok in 11.2

In[1]:= Table[Subscript[a, p], {p, {0, 1, x, x + 1}}]

Out[1]= {Subscript[a, 0], Subscript[a, 1], Subscript[a, x], \
Subscript[a, 1 + x]}

Hi,

I cannot reproduce that in any of the recent versions of MMA.

Table[Subscript[a, p], {p, {0, 1, x, x + 1}}]

gives

{Subscript[a, 0], Subscript[a, 1], Subscript[a, x], Subscript[a, 1 + x]}

What version are you using? Can you start a new Kernel session?

Best wishes,
Marco

PS: Sorry, the last post only showed up after I had submitted… Sometimes there is a long delay…

Hey,
Thanks. Whenever i start a new Kernel session then it works, however i can’t reuse a variable in the same kernel (mathematica is not holding a variable somehow)! I am using 10.4 by the way.
Best wishes,
Shahzeb