Win10
Psychopy v2022.2.4
What are you trying to achieve?:
I am trying to finish a loop either when participants reach a good performance (5 trials are correct) or when they have already done 36 trials.
What did you try to make it work?:
I created two variables that I defined at the “Begin Experiment”
practice_points = 0
correct_decision = []
practice_trials = 0
and at “End Routine”, I tried to create a loop that checks whether they performed well enough or they reached the maximum number of trials. Every trial, practice_trials increase 1.
if practice_points >= 5 or practice_trials >= 36:
practice_trials.finished = True #practice_trials is the name of my loop
elif practice_points < 5 or practice_trials < 36:
if (mouse.getPressed()[0] == 1) and (trial == 1 or trial == 2):
print('trial', trial)
print('correct_press')
practice_points += 1
print('practice_points',practice_points)
correct_decision = 1
print('corr_dec',correct_decision)
practice_trials += 1
What specifically went wrong when you tried that?:
I get the following error:
if practice_points >= 5 or practice_trials >= 36:
TypeError: '>=' not supported between instances of 'TrialHandler' and 'int'
I tried putting int() before the variables, eg. int(practice_trials), but I get this error:
if int(practice_points) >= 5 or int(practice_trials) >= 36:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'TrialHandler'
Could someone please help me define my variables so I can use these statements?