Altering dictionaries/keys in Python
Question: I have ran the code below in Python to generate a list of words and their
count from a text file. How would I go about filtering out words from my
"frequency_list" variable that only have a count of 1?

In addition, how would I export the print statement loop at the bottom to a
CSV

Thanks in advance for any help provided.

    
    
    import re
    import string
    frequency = {}
    document_text = open('Words.txt', 'r')
    text_string = document_text.read().lower()
    match_pattern = re.findall(r'\b[a-z]{3,15}\b', text_string)
    
    for word in match_pattern:
        count = frequency.get(word,0)
        frequency[word] = count + 1
    
    frequency_list = frequency.keys()
    
    
    
    for words in frequency_list:
        print (words, frequency[words])
    


Answer: For the first part - you can use dict comprehension:

`frequency = {k:v for k,v in frequency.items() if v>1}`

