Selecting a specific cube in an array to change properties I am trying to iterate over an array of cubes that I created and assign a new location to each one. I am having trouble with my iterating code. I know the issue is somewhere in how I am referencing each cube.
import bpy


cubes = []
for i in range(10):
    cubes.append(bpy.ops.mesh.primitive_cube_add(size=1, location=(i*2, 0, 0)))
 

 
for cube in cubes:
    
    cube.keyframe_insert(data_path='location', frame = 1)
    cube.location = (10,0,0)
    cube.keyframe_insert(data_path='location', frame = 120)
This operator does not return a reference for the created object.,
bpy.ops.mesh.primitive_cube_add(size=1, location=(i*2, 0, 0)))

so change to the following.
bpy.ops.mesh.primitive_cube_add(size=1, location=(i*2, 0, 0))
cubes.append(bpy.context.active_object)