from collections import Counter words = ['a', 'b', 'c', 'a'] Counter(words).keys() # equals to list(set(words)) Counter(words).values() # counts the elements' frequency