parsing/syntax error using Mosaic to New Raster in loop

Discussion created by dlschwalm on Apr 25, 2014
Latest reply on Apr 26, 2014 by lpinner
Hey all:

I'm new to Python coding language, and find myself stuck on what I'm guessing is a straightforward issue.  Nonetheless, I've been battling this for 2 days now, and no amount of changes to the syntax nor searching for hints online has lead me to the solution.

In short, I am running Arc 10.1 and attempting to script a for loop to process a series of rasters in a directory using the Mosaic to New Raster followed by several manipulations of the subsequent output.  I am receiving the error message "Parsing error SyntaxError: invalid syntax (line 7)". 

If I understand how Python counts lines of code, this points to the line regarding the Mosaic to New Raster calculation. I've double checked this line against examples from the ArcGIS help pages and from other forums online, and it looks to be properly formatted - but Python does not agree! It could also be the line following the Mosaic to New Raster command, which calls the spatial analyst extension - but that also *seems* to be formatted correctly...

Here is my code (try not the grimace, I know it's probably pretty rudimentary to you gurus):
import arcpy
from arcpy.sa import*
from operator import itemgetter

arcpy.env.workspace = "C:/Workspace_DSchwalm/GIS/DataLayers/2014_PredictionGrids/TEST/2011to2040"

rasterList = arcpy.ListRasters() #list of all rasters in the target folder

mosaicNames = ["junkamo", "junkbmo"]
clipNames = ["junkac", "junkbc"]
maskNames = ["junkam", "junkbm"]
fragNames = ["junkaf", "junkbf"]
occNames = ["junkaocc", "junkbocc"]
count = 0
habbuf = "C:/Workspace_DSchwalm/GIS/DataLayers/2013_Fragstats/Buffers/romohabbuf"

for raster in rasterList:
mosaicName = itemgetter(count)(mosaicNames) #grab desired mosaic raster name from mosaicNames list
clipName = itemgetter(count)(clipNames)  #grab desired clipped raster name from clipNames list
maskName = itemgetter(count)(maskNames)  #grab desired mask raster name from maskNames list
fragName = itemgetter(count)(fragNames)  #grab desired fragstats raster name from fragNames list
occName = itemgetter(count)(occNames)  #grab desired occupancy raster name from occNames list
arcpy.MosaicToNewRaster_management(raster;habbuf,"C:/Workspace_DSchwalm/GIS/DataLayers/2014_PredictionGrids/TEST/2011to2040", mosaicName, "#", "8_BIT_UNSIGNED", "#", "1", "FIRST","FIRST")
clipName = Times(mosaicName, habbuf)
arcpy.gp.Reclassify_sa(clipName,"VALUE","0 0.40000000000000002 NODATA;0.40000000000000002 1 1",maskName,"DATA")
arcpy.gp.Reclassify_sa(maskName,"VALUE","1 1;NODATA 0",fragName,"DATA")
occName = Times(maskName, mosaicName)
count = count + 1 #advance the count by 1

Any ideas what is wrong with my syntax, or what other error(s) I've made to generate the "Parsing error SyntaxError: invalid syntax (line 7)" error message? Many thanks in advance, I much appreciate your help getting my past this glitch!