python: if (substring X in string Y) only true for last characters?
<p>This code only returns true when the substring is at the end. How do I fix it to consider any substring? Data looks like this:</p>

<p>prediction: </p>

<ol>
<li><p>dog</p></li>
<li><p>cat</p></li>
</ol>

<p>actual:     </p>

<ol>
<li><p>red,dog</p></li>
<li><p>cat,blue</p></li>
</ol>

<p>returns true then returns false</p>

<pre><code>with open("test_class.txt") as g:
    prediction = g.readlines()

with open("y_smallTest.txt") as g:
    actual = g.readlines()

for n in range(len(prediction)):
    if prediction[n] in actual[n]:
        correct += 1
    else:
        incorrect +=1
</code></pre>

<p>Edit: .rstrips works! The expected output is true, true</p>

<p><code>'cat' in 'cat,blue'</code> returns True</p>

<p>Please make small change to your script</p>

<pre><code>if prediction[n].strip() in actual[n]
</code></pre>

python python-3.x