Scott Siegler <scott.sieg...@gmail.com> writes: > is there a way to do something like: > [(x,y-1), (x,y+1) for zzz in coord_list] > or something along those lines?
You should read the docs of the itertools module on general principles, since they are very enlightening in many ways. Your particular problem can be handled with itertools.chain: from itertools import chain new_list = chain( ((x,y-1), (x,y+1)) for x,y in coord_list ) You can alternatively write an iterative loop: def gen_expand(coord_list): for x,y in coord_list: yield (x-1,y) yield (x+1, y) new_list = list(gen_expand(coord_list)) -- http://mail.python.org/mailman/listinfo/python-list