Counting words in text - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Counting words in text (/thread-14012.html) |
Counting words in text - dan789 - Nov-11-2018 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. RE: Counting words in text - Larz60+ - Nov-11-2018 show us what you have done so far, and where you are having trouble. RE: Counting words in text - dan789 - Nov-11-2018 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. RE: Counting words in text - Larz60+ - Nov-11-2018 pseudo code: for item in list1: if item in list2: ... RE: Counting words in text - dan789 - Nov-11-2018 Thanks, I have done it. :) |