# How to assign a value to an already existing element of a list? [closed]

I want to do the following. Say I have a list:

test = List[a,b,c]


and I now want to assign some value to elements of that list, so that say if I assign 4 to a, when I input a it spits 4 out. How can I do that?

Only just started with Mathematica, there is probably some very easy answer to that question but I don't seem to be able to figure it out myself. I'd appreciate some help.

• test[[1]] = 4; – march Dec 19 '18 at 16:25
• That just replaces the value in my list, which is not what I'm after. – amator2357 Dec 19 '18 at 16:33
• Related, and possible duplicates: (280), (6511), (10322). – Mr.Wizard Dec 19 '18 at 21:10

test = List[a, b, c];
a
b
c


4

5

6

I would not suggest to rely in that too heavily. It is much more efficient and more useful to store the values in a List and index into it:

list = {4,5,6};
list[[1]]
list[[2]]
list[[3]]


4

5

6

• Thank you for answer. Yeah, you're right. It actually does not work for my case. I guess I should've been more specific when formulating the question. The elements of my list are actually of the form: \alpha_{1} + \alpha_{2},\alpha_{2} + \alpha_{3},\alpha_{1} + \alpha_{2} + \alpha_{3}, etc. I know that it is not advisable to use subscripts in Wolfram but in my case it simply makes everything more understandable, especially in terms of the theory behind. – amator2357 Dec 19 '18 at 16:28
• The simple way to subscript is to use a[1], a[2], a[3] ... i.e the symbol with single square brackets. This can be used in symbolic form too as a[n]. Curly brackets i.e. {.} indicate a list and are best only used for that. – Hugh Dec 19 '18 at 16:47
• Thanks Hugh. I didn't use curly brackets for subscripts. I've written it that way in the comment above in order to illustrate what the elements in my list really look like, following latex kind of style of writing. – amator2357 Dec 19 '18 at 16:54
• @amator2357 There is absolutely no point in saying, that "my list are actually of the form: [latex syntax following]" when you are dealing with Mathematica issue. Moreover, Subscript id definitely a way to "everything more understandable". What you actually want is \[Alpha] = {4,5,6};. Indexing into that is done with \[Alpha][[1]] and so on. Then you can also write \[Alpha][[1]] = 4. – Henrik Schumacher Dec 19 '18 at 17:08