title: Using a dictionary to assign misspelled words to its line number
body: <p>This is the code I currently have:</p>
  
  <pre><code>from collections import defaultdict
  
  goodwords = set()
  
  with open("soccer.txt", "rt") as f:
       for word in f.readlines():
          goodwords.add(word.strip())
  
  badwords = defaultdict(list)
  
  with open("soccer.txt", "rt") as f:
      for line_no, line in enumerate(f):
          for word in line.split():
              if word not in text:
                  badwords[word].append(line_no)
  
  print(badwords)
  </code></pre>
  
  <p>How can I fix my code so that it prints the incorrect words stored inside the <code>words</code> list and the line number?</p>
  
  <p>For example if the word <code>togeher</code> was misspelled on lines 5 and 7, it would print something like:</p>
  
  <pre><code>togeher 5 7
  </code></pre>