collections.Counter()

  • + 1 comment

    This works but is much less efficient compared to using the Counter class. List's remove() method has to do a sequential scan through the list in order to find the element to remove, while the Counter class can almost instantly find it by calculating a hash value.