-2
I have this code that counts the number of occurrences of a string in a.txt file and returns it to me. But I would like to use a list of items or an array. And that he would return to me the occurrence of each of these items. The current code is this:
word = "12510537019"
def counting(Text_File, Word):
Data = open(Text_File, "r").read()
count = Data.count(Word)
print(Word, ":", count)
counting("arquivo.txt", word)
But I’d like to start with something like this:
word = [
"12510537019",
"21185356784",
"22097245854",
"16427169000",
"12464413424",
"13506742816",
"11990657689"]
How to do?
What you want is to count the frequency of each word in a text from a list of words? That is, the amount of each word in the list in the text?
– Paulo Marques