Create a list based on the subject's responses, and then use it in another loop

Hi dear friends :pray:

I’m quite new in PsychoPy and I’m facing some challenges.
Then, I would love to get some help from your knowledge :slight_smile:

What are you trying to achieve?:
Using four details from a list that is created during the experiment based on subjects responses.

What did you try to make it work?:
I am currently trying to create a list based on the subject’s responses, and then use it in another loop, which will display only four items from the list.
The list will contain only items that are answered correctly.

What specifically went wrong when you tried that?:

  1. The list is not created for me…
  2. I don’t know how to access the list.

image

Much Appreciate !
Imbar.

The error here is not that the list is not created, it’s that the thing you’re trying to append to the list (LN_names_n) doesn’t exist. As such, you receive an error because you’re trying to append to your list something that doesn’t exist. The solution here is to figure out the correct name of the thing you’re trying to append—other than that, the code snippets visible there look correct to me.

2 Likes

Hi dear ps2!
Thank you very much for the answer, it worked :innocent:

I would appreciate it if you could help me with one more little thing…
Do you know how can I use an item that enters the list in another loop text stimulus?

I’m not 100% sure how this would be achieved in Builder, as I predominantly code my experiments directly. From a coding perspective, it should be as simple as stimulus.text = list[index], where stimulus is the name of the text stimulus in which you want the item to be displayed, list is the name of the list in which the item is saved, and index is the index of the relevant item within that list.

Within Builder, I think you can access variables by prefacing their names with a dollar-sign (e.g., if you wanted to set the text within a text stimulus to be equal to whatever is held in the coolVar variable, you would write “$coolVar” in the relevant entry in the dialog box within Builder). If this is correct, one way to achieve what you want should be to save the relevant item from the list into some variable in a code snippet, and then set the name of that variable as the text value in the appropriate text stimulus. However, others who are more familiar with Builder may see a problem with this and/or be able to suggest a more efficient way to achieve the result you want.

Hi ps2,

Thank you very much for your very helpful solutions!

I’ve add $list[index] inside the text in my stimulus and it worked :pray:

Much appreciated!
Imbar.