I'm trying to create a dictionary of words from a text file and then count the instance of each word and be able to search for a word in the dictionary and receive its count but I am at a stand still. I am having the most trouble making the text file words lowercase and removing their punctuation because otherwise my count will be off. Any suggestions?
f=open("C:\Users\Mark\Desktop\jefferson.txt","r")
wc={}
words = f.read().split()
count = 0
i = 0
for line in f: count += len(line.split())
for w in words: if i < count: words[i].translate(None, string.punctuation).lower() i += 1 else: i += 1 print words
for w in words: if w not in wc: wc[w] = 1 else: wc[w] += 1
print wc['states']