I wanted to make program, that will split every word in txt file, and the return list of words but without repetition of any word. I converted my pdf book to txt and then used my program, but it failed totally. I have no idea, what I've done wrong. Here's my code:
def split(file):
lines = open(file, 'rU').readlines()
words = []
word = ''
for line in lines:
for letter in line:
if letter not in [' ', '\n', '.', ',']:
word += letter
elif letter in [' ', '\n', '.', ',']:
if word not in words:
words.append(word)
word = ''
words.sort()
return words
for word in split('AKiss.txt'):
print(word, end=' ')
I also attached AKiss.txt and original PDF in case it could be useful.