Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

reverse list issue

edited July 2020 in OpenSesame

Hello

I have a corsi memory task all ready running with an inline.

In the task after 4 correct responses for a sequence of n trials, the experiment moves to a sequence of n+1.

If there were less then 4 out of 7 correct answers, the experiment ends.

Now I want to turn it into a working memory task so the correct order is the reverse order.

I am trying to change:

stiseq = sequence of stimlui
respseq = sequence of responses made by the participant
if stiseq==rspseq:
var.set(u'acc', u'1')
else:
var.set(u'acc', u'0')


to this:

if stiseq==rspseq.reverse():
var.set(u'acc', u'1')
else:
var.set(u'acc', u'0')

I am getting the right values of stiseq and respseq,

but for some reson, acc always equals 0.

Any thought as to why this can happen? what have I done wrong?


Thank you!

Comments

  • Hi @labovich ,

    The list.reverse() function doesn't return the list in reverse order. Rather, it changes the list itself (inplace) such that the elements are reversed. But the return value of list.reverse() is always None .

    The normal (but pretty unintuitive) way to return a reversed list is by slicing with steps of -1, like so: l[::-1] . In your case, this might work:

    if stiseq == rspseq[::-1]:
        var.set(u'acc', u'1')
    else:
        var.set(u'acc', u'0')
    

    Cheer!

    Sebastiaan

  • Genius! Thank you so much!!

Sign In or Register to comment.