I'm trying to make a word cloud. I need to strip a txt file of uninteresting words and punctuations. The grader just isn't giving me any feedback. I think my script removes some extra words and I can't figure out why. Can someone point me in the right direction?
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
uninteresting_words = ["the", "a", "to", "if", "is", "it", "of", "and", "or", "an", "as", "i", "me", "my", \
"we", "our", "ours", "you", "your", "yours", "he", "she", "him", "his", "her", "hers", "its", "they", "them", \
"their", "what", "which", "who", "whom", "this", "that", "am", "are", "was", "were", "be", "been", "being", \
"have", "has", "had", "do", "does", "did", "but", "at", "by", "with", "from", "here", "when", "where", "how", \
"all", "any", "both", "each", "few", "more", "some", "such", "no", "nor", "too", "very", "can", "will", "just"]
def count(file_contents):
frequencies = {}
word_list = file_contents.split()
final_list = []
#remove all uninteresting words
for word in word_list:
new_word = ""
for character in word:
if character not in punctuations and character.isalpha():
new_word += character
if word.lower() not in uninteresting_words:
final_list.append(new_word)
for word in final_list:
if word not in frequencies:
frequencies[word] = 0
frequencies[word] += 1
return frequencies