Python Similar Code Different Output
<p>In the python interpreter I enter the following code:</p>

<pre><code>params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secre
t"}

print "&amp;".join("%s_%s" % (i,y) for i,y in params.items())
</code></pre>

<p>And, understandably, I get the following output:</p>

<pre><code>pwd_secret&amp;database_master&amp;uid_sa&amp;server_mpilgrim
</code></pre>

<p>But when I run the the following code:</p>

<pre><code>for i,y in params.items():
    print "&amp;".join("%s_%s" % (i,y))
</code></pre>

<p>I get this strange output:</p>

<pre><code>p&amp;w&amp;d&amp;_&amp;s&amp;e&amp;c&amp;r&amp;e&amp;t
d&amp;a&amp;t&amp;a&amp;b&amp;a&amp;s&amp;e&amp;_&amp;m&amp;a&amp;s&amp;t&amp;e&amp;r
u&amp;i&amp;d&amp;_&amp;s&amp;a
s&amp;e&amp;r&amp;v&amp;e&amp;r&amp;_&amp;m&amp;p&amp;i&amp;l&amp;g&amp;r&amp;i&amp;m
</code></pre>

<p>Both code blocks seem to do the same thing. Why is the output different?</p>
