How do you combine variables to form function in python?
<pre><code>ypos = 1
ypos2 = ypos-1
xpos = 1
xpos2 = 2
</code></pre>

<p>Using these variables, that are changed each time the code loops, how do I get it to print the result below?</p>

<pre><code>=B(ypos)-B(ypos2)
</code></pre>

<p>Every time the code loops the ypos increases by one and therefore the ypos2 increases by one</p>

<p>so as the code loops the results should be
1) B1-B0
2) B2-B1
3) B3-B2
etc.</p>

<p>Any help is much appreciated, and if you don't understand the question let me know, I wasn't quite sure how to explain it.(P.S. I am using python2.7)</p>

<p>Thanks, Anthony</p>

<p>This should be it:</p>

<pre><code>print 'B({})-B({})'.format(ypos, ypos2)
</code></pre>

<p>For python2.7 prints are without parentheses, unlike in python3. Check this to verify <a href="https://docs.python.org/2/tutorial/inputoutput.html" rel="nofollow">link</a></p>

python excel string python-2.7 function