Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Counting words in text
Hello, can you explain to me, how to count words in some text and make a list consisting of couples in form: [(word, number of appearances),(word,number),(word,number)...]?

Thanks in advance for your help.
show us what you have done so far, and where you are having trouble.
Ok, but none of my attempts was succesful.

I was thinking about creating 2 lists - one consisting of all different words and the second one of numbers - whilst list2[0] represents number of appearances of word list1[0] and so on. But the problem with this is, that it´s no way how am I able to create one list with these couples, or at least I don´t know how to such a couple list create, from syntax aspect.
pseudo code:
for item in list1:
    if item in list2:
Thanks, I have done it. :)

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Open and read multiple text files and match words kozaizsvemira 2 306 Sep-11-2019, 12:58 PM
Last Post: kozaizsvemira
  Counting words in the last line of a file Drone4four 15 1,191 May-31-2019, 09:30 PM
Last Post: snippsat
  Compare all words in input() to all words in file Trianne 1 613 Oct-05-2018, 06:27 PM
Last Post: ichabod801
  Python - Limit Sentence Length to 10 Words - Text file dj99 2 1,386 Jul-21-2018, 02:24 PM
Last Post: dj99
  Searching a text file to find words matching a pattern Micael 3 20,478 Nov-07-2017, 08:52 PM
Last Post: Micael

Forum Jump:

Users browsing this thread: 1 Guest(s)