title: Python: Accessing dictionary using variable as the key
body: <p>I'm trying to access a dictionary by using a variable that I've set previously.</p>
  <pre><code>myvar1 = 1
  mydict =  {'1': ['apple', 20, 80, 40],
      '2': ['orange', 81, 400, 100]}
  
  myvar2 = mydict[myvar1][0]
  print(myvar2)
  </code></pre>
  <p>This gives me KeyError: 1</p>
  <p>I've also tried</p>
  <pre><code>myvar2 = mydict['myvar1'][0]
  </code></pre>
  <p>This gives me KeyError: 'myvar1'</p>
  <p>Clearly I am missing something basic.</p>