title: How should a variable be passed within format() in Python?
body: <p>I am seeking to be able to use variables within the format() parentheses, in order to parameterize it within a function. Providing an example below:</p>
  
  <pre><code>sample_str = 'sample_str_{nvars}'
  nvars_test = 'apple'
  sample_str.format(nvars = nvars_test)  #Successful Result: ''sample_str_apple''
  </code></pre>
  
  <p>But the following does not work - </p>
  
  <pre><code>sample_str = 'sample_str_{nvars}'
  nvars_test_2 = 'nvars = apple'
  sample_str.format(nvars_test_2) # KeyError: 'nvars'
  </code></pre>
  
  <p>Would anyone know how to do this? Thanks.</p>