Dynamically call a var inside string in function
<p>I'm new to python, I have var (string) which is an <em>Xpath</em> query. I want to pass the variable <em><code>i</code></em> into the <em>Xpath</em> query. A simple example  below:</p>

<pre><code>i = 0
self.var = 'li['+i+']'

def test(self):
  while(i&lt;10):
   print self.var #  'li[0]', 'li[1]' ...
   i += 1
</code></pre>

<p>You can create a list with the first string, the integer, and the second string. </p>

<pre><code>i = 0
var = ['li[',i,']']

def test(var):    
    while(var[1]&lt;10):
        print var[0]+str(var[1])+var[2]
        var[1] += 1

test(var)
</code></pre>

python