python string formatting portion cut off
<p>I'm a total beginner and this is my first question so I know this is probably stupid. But in python when I try and format a string with this code:</p>

<pre><code>x = 7
print "% how do you do" % (x)
</code></pre>

<p>I get this as a result:</p>

<pre><code>7w do you do
</code></pre>

<p>Is there a reason why the "ho" in "how" is getting cut off?</p>

<p>Best solution here is to use <code>format</code> function.</p>

<pre><code>&gt;&gt;&gt; '{0} is bigger than {1}'.format('elephant', 'dog')
'elephant is bigger than dog
</code></pre>

<p>You can read more about formatting in the <a href="https://docs.python.org/3.1/library/string.html#format-examples" rel="nofollow">python documentation</a></p>

python string-formatting