# Taking variables from string

In a mathematica operation I am getting the o/p say, 1->2. For the next step, I want to use these two numbers as variables, say take them as 1 = m and 2 = n. How can I do it.

• 1 = m is not m = 1. – Kuba Jul 26 '17 at 9:58

out = 1 -> 2;

{m, n} = List @@ out;

m


1

n


2

If out would be a string:

out = "1 -> 2";

{m, n} = List @@ ToExpression @ out;