title: Why I get 'dict' has no attribute 'sort' error in my concordance program in Python
body: <p>The task is to write a program which prompts for a filename and then produces a concordance of that file.
  Ex. A concordance is an alphabetical index that shows the lines in a document where each word occurs. For example, a concordance for this paragraph might appear as:</p>
  
  <pre><code>Word          Line Number
  a             1 1 2
  alphabetical  1
  an            1
  appear        2
  </code></pre>
  
  <p>Here I make a list so that I can sort the words.</p>
  
  <p>I have this code:</p>
  
  <pre><code>f = open(raw_input("Enter a filename: "), "r")
  myDict = {}
  linenum = 0
  
  for line in f:
  line = line.strip()
  line = line.lower()
  line = line.split()
  linenum += 1
  
  for word in line:
      word = word.strip()
      word = word.lower()
      myDict[word] = linenum
  
      if word in myDict:
          myDict.sort()
      else:
          myDict.append(word)
  
  print "%-15s %-15s" %("Word", "Line Number")
  print "%-15s %-15d" %(myDict.keys(), myDict.values())
  </code></pre>
  
  <p>When I run the program now it says 'dict' has no attribute 'sort'. Can you explain this please?</p>
  
  <p>The file is the same as the example and the output should also be the example from above. I'm very new at python please help :[</p>