Python If Variable in Variable
<p>I Have Made A File Called <code>helloworld.simon</code>.
In There I  Have Written:</p>

<pre><code>Public class helloworld {
main = (main.method());
main {
    console.print("Hello World");
    }
</code></pre>

<p>And I Have Written This Code:</p>

<pre><code>Public = ("Public")
Private = ("Private")
code = open('helloworld.simon' , 'r')
print(code.read())
if Public in code:
    print("Pub")
else:
    print("J")
</code></pre>

<p>And The <em>Output</em> Is:</p>

<pre><code>Public class helloworld {
main = (main.method());
main {
    console.print("Hello World");
    }

J
</code></pre>

<p>Change this line:</p>

<p><code>code = open('helloworld.simon' , 'r')</code></p>

<p>To this:</p>

<pre><code>with open('helloworld.simon' , 'r') as f:
   lines = f.readlines()
   if any([line for line in lines if Public in line]):
      print("Pub")
   else:
      print("J")
</code></pre>

python file filereader