You need a string to split. I updated your code a little ...
#import string # old stuff
#ofile=open(raw_input("Please enter the name of a text file :"))
# open a text file you have for testing ...
ofile = open("atest.txt")
# read text in as one string s
s = ofile.read()
print s
print
word_freq = {}
# split text string s on white spaces
word_list = s.split()
for word in word_list:
count = word_freq.get(word.lower(),0)
word_freq[word.lower()] = count + 1
keys = word_freq.keys()
keys.sort()
for word in keys:
print word, word_freq[word]
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417