title: get value of a variable if the string name is the exact same
body: <p>consider we have a set of variables A,B,C, .. X,Y,Z all already defined, with each variable representing an integer 0,1,2, ... 23,24,25 respectively.</p>
  <p>e.g. A = 0, B = 1</p>
  <p>Now I would like to write code which takes the name of the variable as an input and returns their values after processing them.</p>
  <p>Here is some example code to perform this.</p>
  <pre><code>inp1 = input(&quot;Enter letter 1-&gt;&quot;)
  inp2 = input(&quot;Enter letter 2-&gt;&quot;)
  
  def connect(inp1,inp2):
      print(str(inp1) + &quot; = &quot; + str(inp2) + &quot;\n&quot;)
  </code></pre>
  <p>which I would like to return</p>
  <pre><code>0 = 1
  </code></pre>
  <p>if the inputs were A, B.</p>
  <p>Currently the code would produce this result instead, as the data inputted is in string format:</p>
  <pre><code>A = B
  </code></pre>
  <p>To get around this I have made a small function to get the value from the string input:</p>
  <pre><code>def get_value(x):
      if x == &quot;A&quot;:
          return A
      elif x == &quot;B&quot;:
          return B
  </code></pre>
  <p>As you can see, this is infeasible for a large number of variables as I would have to write these rules for every variable. I would like to know if there is a way to get the value without using this function (Which simply returns the value if the string name is the same) e.g. by using a built-in function.</p>
  <p>Apologies for my english,
  Forp</p>
  <p>For reference, here is my example code completed:</p>
  <pre><code>A = 0
  B = 1
  inp1 = &quot;A&quot;
  inp2 = &quot;B&quot;
  
  def get_value(char):
      if char == &quot;A&quot;:
          return A
      elif char == &quot;B&quot;:
          return B
  
  def connect(inp1,inp2):
      part1 = get_value(inp1)
      part2 = get_value(inp2)
      print(str(part1) + &quot; = &quot; + str(part2) + &quot;\n&quot;)
  
  connect(inp1,inp2)
  </code></pre>