Since the correct answer also depends on the location, you could have:
Begin Experiment
locations = [[(-0.5, 0),'left'], [(0.5, 0),'right']]
Begin Routine
shuffle(locations)
thisExp.addData('Answer',locations[0][1])
with the image position set to locations[0][0] Each Repeat and the keyboard correct answer set to locations[0][1]