still get the same error
Code:
import sys
import string
text = []
infile = open(sys.argv[1], 'r').read()
for punct in string.punctuation:
infile = infile.replace(punct, "")
text = infile.split("\n")
dict = open(sys.argv[2], 'r').read()
dictset = []
dictset = dict.split()
words = []
words = list(set(text) - set(dictset))
words = [text.lower() for text in words]
words.sort()
def findline(text, word):
ans = []
reps = text.count(word)
n = 0
for i in range(reps):
ans.append(text[n:].index(word)+n)
n = text[n:].index(word)+1
return ans
for w in words:
print(w,findline(text, w)
Comment