Flip screen every key press

I am trying to collect the amount of space bar presses a subject can make in three seconds. Visually, I am displaying an empty bar on the screen at the onset of the trial, and every time the subject presses the space bar, I want to draw a new image with a bit of that bar being filled (to display progress). I am having trouble updating the image every space press. Here is what I have at the moment. On the second press, I would like to draw calibration_slide_2, on the third press I would like to draw calibration_slide_3, and so on.

calibration_time = 3
number_of_upates = 12
calibration_update_duration = .25
calibration_total_presses = 0

timer.reset()
while timer.getTime() < 3:
    
    current_time = timer.getTime()
    key = kb.getKeys()
    
    if 'space' in key:
        calibration_total_presses = calibration_total_presses + 1
        print (calibration_total_presses)
        calibration_slide_1.draw()
        win.flip()

One way to do this is to access the globals - this essentially means you can index the workspace like a dict, and then you can get objects by constructing their name as a string. So the code would look like:

globals()['calibration_slide_'+str(calibration_total_presses )].draw()

However, this is a bit of a ‘fast & dirty’ solution. A much cleaner way to do it would be to put all of the calibration slides into a list, like this:

calibration_slides = [
    calibration_slide_1,
    calibration_slide_2,
    calibration_slide_3,
    calibration_slide_4,
    calibration_slide_5,
    calibration_slide_6,
    etc.
]

and then index that list using calibration_total_presses.