Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78699
| From | Shiva <shivaji_tn@yahoo.com> |
|---|---|
| Subject | Re: Issue in printing top 20 dictionary items by dictionary value |
| Date | 2014-10-04 17:36 +0000 |
| References | <mailman.14596.1412413918.18130.python-list@python.org> <m0oi4p$7ir$1@speranza.aioe.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14602.1412444228.18130.python-list@python.org> (permalink) |
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??
Thanks,
Shiva
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Issue in printing top 20 dictionary items by dictionary value Shiva <shivaji_tn@yahoo.com> - 2014-10-04 09:11 +0000
Re: Issue in printing top 20 dictionary items by dictionary value Alexander Blinne <news@blinne.net> - 2014-10-04 12:28 +0200
Re: Issue in printing top 20 dictionary items by dictionary value Shiva <shivaji_tn@yahoo.com> - 2014-10-04 17:36 +0000
Re: Issue in printing top 20 dictionary items by dictionary value Larry Hudson <orgnut@yahoo.com> - 2014-10-04 14:44 -0700
Re: Issue in printing top 20 dictionary items by dictionary value Shiva <shivaji_tn@yahoo.com> - 2014-10-05 06:58 +0000
Re: Issue in printing top 20 dictionary items by dictionary value MRAB <python@mrabarnett.plus.com> - 2014-10-04 20:40 +0100
Re: Issue in printing top 20 dictionary items by dictionary value Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-05 01:11 +0000
Re: Issue in printing top 20 dictionary items by dictionary value MRAB <python@mrabarnett.plus.com> - 2014-10-05 02:41 +0100
csiph-web