Hi I'm trying to write a function that takes a variable number of lists that can contain any number of words. What I am hoping to return is a dictionary where the words are the keys and the values are the total count of each word in all of the lists.
My code works with a single list:
wl1 = ['double', 'triple', 'int', 'quadruple']
new_dict = {}
for i in range(len(wl1)):
new_dict[wl1[i]] = wl1.count(wl1[i])
and returns this:
{'double': 1, 'triple': 1, 'int': 1, 'quadruple': 1}
But it doesn't work with multiple lists and shows an unhashable list type:
def varlist(*items):
newdict = {}
for i in range(len(items)):
newdict[items[i]] = items.count(items[i])
return (newdict)
Should I be using **kwargs instead to make it into a dictionary? And if so, would I change variable list items into a dictionary using their frequency count? Any tips would be super helpful.