Your explanation is correct. It's important to realise that effectively the input many thousands of single bets come out of a black box and it is then necessary for me to merge them into the grouped format to make things more manageable. Given an arbitrary bucket of single bets, it is by no means obvious how they should be grouped without doing something algorithmic. In grouping, it is also important to not inadvertently introduce any new single bets.
For the purpose of this discussion, I am also assuming that all bets are the same size. That's not the case, but can leave that little twist for another day. -- http://mail.python.org/mailman/listinfo/python-list