finding an amount of variable in a text file by python
<p>I have a variable which its amount is changing every time. I like to know how can I find the line which contained the amount of my variable.
I am looking something like this:
but in this way it looks for the letter of "A"
how can I write a command which look for its amount("100")?
I tried this before</p>

<pre><code>A = 100
with open ('my_file') as f:
    for line in f :
        if "A" in line:
           print line
</code></pre>

<p>Putting quotes around something makes it a String. You want to actually reference the variable which contains your number, i.e. <code>A</code> instead of <code>"A"</code></p>

<pre><code>A = 100
with open('my_file') as f:
    for line in f:
        # str() converts an integer into a string for searching.
        if str(A) in line:
            print line
</code></pre>

python variables text