python print a line, if and only if x and y are found
<p>I'm trying to print a line that contains specific keywords, and they both should be in the same line in order for it to print out.</p>

<p>This is how I approached the problem, I  made 2 variables and assigned them with the variables. One of them is a filename and that changes every time the program iterated through a list. </p>

<pre><code>for files in myfiles:
       for lines in info:
             if dir_key and files in lines:
                      print lines
             else:
                 print "line not found" 
</code></pre>

<p>This works, but the problem is, it also prints a line that only contains the filename. How do I ensure it doesn't do that ?. I tried the </p>

<pre><code>if line.beginswith(dir_key) and line.endswith(file)
</code></pre>

<p>but that yielded no results what so ever. so I switched to the first method.</p>
