title: Python check for word in list
body: <p>I'm writing a spell checking function and I'm using two text files: one that has misspelled text and a text file with a bunch of words from the dictionary. I have turned the text of misspelled words into a list of strings and the text file with dictionary words into a list of words. Now I need to see if the words in my misspelled list are in my list of dictionary words. </p>
  
  <pre><code>def spellCheck():
      checkFile=input('Enter file name: ')
      inFile=open(checkFile,'r')
  
  # This separates my original text file into a list like this
  # [['It','was','the','besst','of','times,'],
  # ['it','was','teh','worst','of','times']]
  
      separate=[]
      for line in inFile:
          separate.append(line.split())
  
  # This opens my list of words from the dictionary and 
  # turns it into a list of the words.
  
      wordFile=open('words.txt','r')
      words=wordFile.read()
      wordList=(list(words.split()))
      wordFile.close()
  
  
  # I need this newList to be a list of the correctly spelled words 
  # in my separate[] list and if the word isn't spelled correctly 
  # it will go into another if statement... 
  
      newList=[]
      for word in separate:
          if word in wordList:
              newList.append(word)
      return newList
  </code></pre>