| Reference | Downloads | Github

Iterating through list in pavlovia

Description of the problem: I trying to end a routine if the user makes three consecteitve bull eyes called ‘hits’. I am trying to iterate through a list and for that I need to tell python the len of the list but pavlovia is not liking this, even when converted to JS. I’ve now tried the code below which does not explicitly use the len function but I am still getting the same error. Do you have any insight on how to approach this?

def list_count(the_list):
total = 0
for each_element in the_list:
total = total + 1
return total
size = list_count(feedback_history_list)
for i in range(size - 2):
# checking the conditions
if feedback_history_list[i] == feedback_history_list[i + 1] and feedback_history_list[i + 1] == arr[i + 2]:
# printing the element as the
# conditions are satisfied
if feedback_history_list[i] == ‘HIT’:

type error cannot read property of undefined reading length psychopy

Python and JS already have a length function … len(list) IIRC

However, this seems to be a very complicated method.

Start with hits = 0

If there’s a hit then hits += 1

If there’s a miss then hits = 0

Check if hits == 3