1

My folder has three TIFFs.

enter image description here

But when I use arcpy.ListRasters, it gives three lists that contain nine TIFFs. Why it doesn't give one list containing three TIFFs?

import arcpy
arcpy.env.workspace = "D:/04.crash/t1"
rasters = arcpy.ListRasters("*","TIF")
for raster in rasters:
    print(rasters)

enter image description here

0

1 Answer 1

6

You're printing rasterS -- the variable from your ListRasters. You want to just print raster (no s). Right now you're printing the list 3 times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.