Points not accumulating correctly

I’m having an issue with points not accumulating correctly. On each trial 1 or 10 points should be assigned, but after the first trial the points are increasing by 2, 11, or 20 points. I have a nested if…then to determine the number of points based on the response and the stimuli, and I’ve ruled out multiple conditions being met on a trial. I could use some help figuring out why this code isn’t working correctly. This is code in a builder component.

print(mouse.clicked_name[0])
if mouse.clicked_name[0] == 'left_circle':
    if (leftStim =="square" or leftStim == "circle"):
        print('left_lo')
        points_trial = 1
        points_cumul += points_trial
    elif (leftStim == "star" or leftStim == "hexagon"):
        print('left_hi')
        points_trial = 10
        points_cumul += points_trial
elif mouse.clicked_name[0] == 'right_circle':
    if (rightStim =="square" or rightStim == "circle"):
        print('right_lo')
        points_trial = 1
        points_cumul += points_trial
    elif (rightStim == "star" or rightStim == "hexagon"):
        print('right_hi')
        points_trial = 10
        points_cumul += points_trial

fback_text = f'+{points_trial}\n{points_cumul} total'
print(fback_text)

and this is the debug output I’m getting:

left_circle
left_lo
+1
1 total

left_circle
left_hi
+10
12 total

left_circle
left_lo
+1
23 total

left_circle
left_lo
+1
25 total

left_circle
left_hi
+10
36 total

left_circle
left_hi
+10
56 total

Based on your results you must have another copy of this line after the print statement but before the points_trial is reset to 0

Yup that was it - I compiled the code to try to find it and it looks like my student must have put that addition code in the EndRoutine tab as well. I didn’t think to look there since only the BeginRoutine tab had an asterisk. What does it mean when a code component tab has an asterisk? I just assumed it meant there was code there.

Joe

Was the component set to Both? I think that the asterisk only tells you about code on the Python side.