> Is there a quick and simple way to sort a set of values (strings in this > case) into a set of bins, based on a subset of the characters in the > string? mylist = ['0101', '0102', '0103', '0201', '0202', '0203'] mybins = {} for s in mylist: bin = s[-2:] mybins.setdefault(bin, []).append(s) print mybins -- Jason Orendorff http://www.jorendorff.com/