On Sat, May 7, 2016, at 06:16 PM, DFS wrote: > Why is it better to zip() them up and use: > > for item1, item2, item3 in zip(list1, list2, list3): > do something with the items > > than > > for j in range(len(list1)): > do something with list1[j], list2[j], list3[j], etc.
Although Chris has a perfectly good and valid answer why conceptually the zip is better, let me put forth: the zip is simply clearer, more readable and more maintainable. This is a question of style and to a certain degree aesthetics, so is somewhat subjective, but range(len(list1)) and list1[j] are all indirection, when item1 is clearly (if given a better name then 'item1') something distinct you're working on. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list