Feb-09-2018, 03:04 AM
content = input('Enter English words:').lower() counters = {} words = content.split() for word in words: word = words if word not in counters: counters [word] = 1 #First occurrence of a word starts counter else: counters [word] += 1 #if repeat word add to existing counter for word, count in counters.items(): print (word, count)
Error: line 8, in <module>
if word not in counters:
builtins.TypeError: unhashable type: 'list'
I am trying to make a word count from words that a user enters and I came to this error and I am unfamiliar with it. If someone could explain or some good material that would help me better understand the error that would be great. Thanks!