title: Python Concordance program - alphabetical order
body: <p>I'm trying to write a program that displays a concordance for a file.  It should output the unique words and their frequencies in alphabetical order.  This is what I have, but it's not working.  Tips?  </p>
  
  <p>FYI - I know NOTHING about computer programming!! I'm taking this class to satisfy a high school math endorsement requirement.</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()
  
      if not word in myDict:
          myDict[word] = []
  
      myDict[word].append(linenum)
  
  
  print "%-15s %-15s" %("Word", "Line Number")
  for key in sorted(myDict):
      print '%-15s: %-15d' % (key, myDict(key))
  </code></pre>