Random movement of objects to X,Y axes
Not sure what do you mean XY axis, But you might misunderstand the subscription for array in python. They should start at 0 not 1. eg. x = [3,6,9]; x[0] # is 3. The Object.location (Vector) stand for [X,Y,Z] So you might need to use location[0], location[1] instead.
Instead of using number to retrieve axis, ones should use properties to get the axis for clearance. eg. location.x = 1.0; location.y = 2.0
import bpy
import random

constrain = (-0.01, 0.01) # I prefer to use tuple for min, max value

for target_obj in bpy.context.selected_objects: # PEP8 recommend to use lower snake case
  target_obj.location.x = random.uniform(*constrain) # And unpack them using *
  target_obj.location.y = random.uniform(*constrain)
  continue
  # Another approach
  target_obj.location.xy = (random.uniform(*constrain), random.uniform(*constrain))
  # There can be called and manipulated by combination as well