On 2014-10-04 18:36, Shiva wrote: > It works : > orderedwords = sorted(textstorage.keys(), key=textstorage.get) > > The method textstorage.get will accept a word and return it's value > which in this instance is the count. > > What I don't understand is: > > for w in eachword: > textstorage[w]=textstorage.get(w, 0) + 1 > > How does textstorage.get(w,0)+1 give the count of the word?? > What textstorage.get(w, 0) says is: if the word is in the dict, return its count, else return 0.
-- https://mail.python.org/mailman/listinfo/python-list