Hello,
I have to count the number of words in a .txt file.
Here is my program so far
import string
ofile=open(raw_input("Please enter the name of a text file :"))
s=ofile.readlines()
print s
word_freq={}
word_list=string.split(s)
for word in word_list:
count=word_freq.get(string.lower(word),0)
word_freq[string.lower(word)]=count+1
keys=word_freq.keys()
keys.sort()
for word in keys:
print word,word_freq[word]
As of now I'm getting a 'AttributeError: 'list' object has no attribute 'split''
Please help me!
Thanks so much,
Joey