Skip to content Skip to sidebar Skip to footer

Code That Creates Variables, And Increments Its Suffix

My first post on Python language as I am learning it. I have a shape file that has around 10000 polygons. I am trying to generate code like below that creates Polygon1, Polygon2 a

Solution 1:

How about something like:

polygons = []
for i in range(10000):
    polygons.append(shape(shapes[i])

Then you can reference the polygons as polygons[j] where j is an index from 0 to 9999.

Post a Comment for "Code That Creates Variables, And Increments Its Suffix"