For example in Python, if we have a list of 3 elements, say ls = [1,2,3] and we want to assign a variable to each value (from left to right), one can do as follows: x,y,z = ls where then, x will take the value 1 and so on.

Now if we have a list in Mathematica ls = {1,2,3}, is there an analogous way of performing the simultaneous assignment?

  • 7
    $\begingroup$ lst={1,2,3}; {x,y,z}=lst should just work as is? $\endgroup$ – Nasser Nov 10 '17 at 14:55
  • $\begingroup$ @Nasser Indeed it does, exactly what I was looking for, thanks. Should I remove the post, or would you prefer to add this as an answer and I accept (maybe relevant for future users). $\endgroup$ – user52181 Nov 10 '17 at 14:58