title: Search a textfile using elements from a dictionary or other data structure in python
body: <p>I'm trying to read in a text file and using a dictionary to see if certain words or other characters appear in the text file. If so how many?</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>d = {}        
  d["keyword"] = ["he","him","his"]
  print d
  keywords = 0
  print ("Opening the file")
  with open('textFile.txt','r') as foo:
      for line in foo:
          elements = line.split()
          for d["keyword"] in elements:
              if d["keyword"] in line:
                  keywords +=1
  
  print keywords
  </code></pre>
  
  <p>the output I want is to print out how many of the keywords were in the file. Right now I'm getting how many totals words there are in my text file. </p>