Python Print Variables with parameters
<p>I know you can do this for a string:</p>

<pre><code>print("You have inputted {0} postive numbers and {1} negative numbers".format('3','2'))
</code></pre>

<p>And this would produce:</p>

<pre><code>You have inputted 3 postive numbers and 2 negative numbers
</code></pre>

<p>But I want to insert a letter in a variable name. For example,</p>

<pre><code>number = 4
print(nu{}ber.format("m"))
</code></pre>

<p>And this should produce <code>4</code> Any ideas?</p>

<p>Though it's not recommended, you can access your variable dynamically through <code>globals</code>:</p>

<pre><code>&gt;&gt;&gt; number = 4
&gt;&gt;&gt; globals()['num' + 'ber']
4
</code></pre>

<p><code>eval</code> works too:</p>

<pre><code>&gt;&gt;&gt; eval('num' + 'ber')
4
</code></pre>

python output