word_freq = {'is': [1, 3, 4, 8, 10],'no' :[1], 'yes':[1,2]}
I want to only get 'is' and 'yes' using the fact that they contain more than one value.
CodePudding user response:
filtered_keys = [k for k in word_freq.keys() if len(word_freq[k])>1]
CodePudding user response:
You can try this:
for i in word_freq:
if len(word_freq[i]) > 1:
print(word_freq[i])
It loops through the dictionary in word_freq
and if the items/values
in the word_freq
are more than 1 then it prints them out.