title: Dictionary with occurence of length of words
body: <p>My function takes a dictionary as input and then displays a text bar plot in the console. That is, it should "print" to the screen the bar plot. The labels of the plot of the are the keys in the dictionary and the bar lengths are determined by the values of the keys.</p>
  
  <p>For example using this dictionary:</p>
  
  <pre><code>{4:2, 3:5, 10:1, 8:1, 5:1}
  </code></pre>
  
  <p>the plot would look like this:</p>
  
  <pre><code>keys|values         
  ----+-------------       
  03|#####       
  04|##   
  05|#  
  08|#  
  10|#
  </code></pre>
  
  <p>The labels (keys) should be displayed in sorted order when making the plot. Each label (key) should be displayed with leading zeros so that each has the same number of digits in it. At the moment all my function does is print the dictionary of a file that has the following sentence:</p>
  
  <blockquote>
    <p>and then the last assignment ended and everyone was sad</p>
  </blockquote>
  
  <pre><code>def wordLengthStats(filename):
      file = open(filename, 'r')
      wordcount={}
      for line in file.read().split():
          if line not in wordcount:
              wordcount[line] = 1
          else:
              wordcount[line] += 1
      for k,v in wordcount.items():
          print (k, v)
      return None
  
  def main():
  
      d = wordLengthStats("sample.txt")
      print("d should be { 3:5, 4:2, 5:1, 8:1, 10:1} ")
      print("d is", d)
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>The sentence is just an example, I am trying to make it so that any input should work. Any help on approaching this problem would be greatly appreciated. Thanks!</p>