extract number from a text file into variable using list
<p>I've a .text file with text</p>

<blockquote>
  <p>.numvar 5</p>
</blockquote>

<p>I want to extract this 5 into a separate variable and use.
I've used list to extract value but, I cannot manipulate the variable.</p>

<pre><code>    if ".numvars" in line:
    splitter=re.compile(r'\d+')
    numvars=splitter.findall(line)
    numvars=map(int, numvars)
</code></pre>

<p>how to store the 5 in separate variable.</p>

<p>How about:</p>

<pre><code>import re

with open("test.txt") as f:
    for line in f:
        if ".numvar" in line:
            splitter = re.compile(r'\d+')
            numvars = splitter.findall(line)
            my_numbers = [int(n) for n in numvars]
            my_number = my_numbers[0]
            print(my_number)
</code></pre>

python list