import collections if __name__ == '__main__': word_list = ['a', 'b', 'a', 'c', 'd', 'e', 'f'] print(collections.Counter(word_list).most_common(1)[0][0]) word_str = 'abcdeaascebd' print(collections.Counter(word_str).most_common(1)[0][0])