Read specfic character from line in Text File(Python)
<pre><code>char1= "P"
length=5
f = open("wl.txt", 'r')

for line in f:
if len(line)==length and line.rstrip() == char1:
   z=Counter(line)
   print z
</code></pre>

<p>I want to output only lines where length=5 and contains character p.So far</p>

<pre><code>  f = open("wl.txt", 'r')
    for line in f:
    if len(line)==length :#This one only works with the length
      z=Counter(line)
      print z
</code></pre>

<p>Any guess someone?</p>
