I need to pass year to the path inside a for loop in python script.
years = [2010,2011,2012] months =  for year in years: for month in months: arcpy.env.workspace = r'H:\Test_ONLY\prism_800m_'+ year[:4] scratch = r'H:\Test_ONLY\scratch' if year % 4 > 0 and month == 9: fmaskrasters1 = fmaskrasters[243:249] fmaskrasters2 = fmaskrasters[249:255] fmaskrasters3 = fmaskrasters[255:261] fmaskrasters4 = fmaskrasters[261:267] fmaskrasters5 = fmaskrasters[267:273] else: print("Not configured in the script!")
I want to change r'H:\Test_ONLY\prism_800m_2010 each time for the months from Sep.
How can I achieve this by modifying the above code. I think I am not doing something right in arcpy.env.workspace = r'H:\Test_ONLY\prism_800m_'+ year[:4]
can somebody help me to correct this?
Thanks in advance.
Solved! Go to Solution.