Help doing it the "python way"

Scott Siegler scott.siegler at gmail.com
Thu May 24 16:22:43 EDT 2012


Hello,

I am an experienced programmer but a beginner to python.  As such, I can figure out a way to code most algorithms using more "C" style syntax.

I am doing something now that I am sure is a more python way but i can't quite get it right.  I was hoping someone might help.

So I have a list of grid coordinates (x, y).  From that list, I want to create a new list that for each coordinate, I add the coordinate just above and just below (x,y+1) and (x,y-1)

right now I am using a for loop to go through all the coordinates and then separate append statements to add the top and bottom.

is there a way to do something like: [(x,y-1), (x,y+1) for zzz in coord_list] or something along those lines?

thanks!



More information about the Python-list mailing list