# Creating a new variable from previous ones

Hi all,

I am creating an experiment that consists of repeating the order in which some squares are illuminated in a 5 square template. The participant has to repeat the same exact order in which the squares are shown.

I need three specific variables. The first one, correct or incorrect for each response. I mean, If the order is 2-5-1 and the participant answers 2-3-2, the variable has to show 1-0-0 or correct, incorrect, incorrect. The second one, correct or incorrect for each sequence. If there is at least one mistake, the entire sequence must be qualified as incorrect. Finally, there are eight levels, each one with four sequences. The third variable, correct or incorrect for each level. If there is at least one correct sequence, the entire level must be qualified as correct. I know how to create and measure the first one, but not how to construct the second one and the third one from its previous variables.

Another doubt is how to create an if statement that stops the experiment if the level is incorrect. I mean, the experiment has to end after an incorrect level.

Thank you so much, I hope you can help me.

## Comments

Hi,

If you provide more information on how you set up your experiment, we can provide a more targeted help to your problem. Right now it is a bit hard to guess how you implemented this paradigm and how to properly help you.

Generally, if you have sequences of 1-0-0 in a list, you can use

`all([1,0,0])`

to find out whether all are correct or at least one is wrong. This you can use to get the second level. If you use`any([1,0,0])`

, on the second level, it will return true if at least one is correct, which should help you getting to the third level, right?Eduard