I have a dictionary. Each key contains a list. I am using the contents of the list to build a portion of a command line.
However, before I can build the command line, I have to make sure that the command isn't too long. This means that I have to step through each item in the list twice: once to check the length and once to build the command. Is there an easier/better way to do this? for key in dict: tlen = 0 for item in dict[key]: tlen = tlen + len(item) if tlen > 200: #break command portion into multiple portions ... for key in dict: for item in dict[key]: #buld command -- http://mail.python.org/mailman/listinfo/python-list