Counting words in a string??

breamoreboy at gmail.com breamoreboy at gmail.com
Fri Sep 30 16:06:15 EDT 2016


On Friday, September 30, 2016 at 8:12:47 PM UTC+1, Jake wrote:
> On Friday, 30 September 2016 19:49:57 UTC+1, srinivas devaki  wrote:
> > On Oct 1, 2016 12:10 AM, "Jake" wrote:
> > >
> > > Hi, I need a program which:
> > > 1) Asks the user for a sentence of their choice (not including
> > punctuation)
> > > 2) Ask the user which word they would like to know is repeated
> > > 3) Print out to the user how many times the word came up which they chose
> > from their sentence.
> > >
> > 
> > typical home work assignment, even though stop asking for programs and
> > start asking how to make the same.
> > 
> > anyway if you ever try to write code for this you have to split you
> > sentence and use a dict for counting
> > 
> > Python has Counter from collections but it is a little bit slower when
> > compared to defaultdict for this kind of purpose.
> > 
> > Regards
> > Srinivas Devaki
> > Senior (final yr) student at Indian Institute of Technology (ISM), Dhanbad
> > Computer Science and Engineering Department
> > ph: +91 9491 383 249
> > telegram_id: @eightnoteight
> 
> ----------
> Could you make the program for me or provide an outline?

We'll start work as soon as your cheque made payable to the Python Software Foundation has been cashed.  It works a bit like the Monty Python "Blackmail" sketch, the higher the grade you want, the more you have to pay.



More information about the Python-list mailing list