psychopy.org | Reference | Downloads | Github

Delete first two items in an array

I’m using the standalone PsychoPy version 3.1.5

During eleven routines I ask participants to make 2 ratings with 2 different sliders. Then, because I need to rank the ratings, I then create an array of the 22 ratings with this code:

rankall = rankall+[int(rating1.text), int(rating2.text)]

The first two rounds of the routine are practice, so I don’t want those two ratings in my array. So, I am trying to find the code to cut out those two items. I have tried several iterations and am having the same problem - it either cuts out one item or four. Here’s the current code I’ve tried:

In order to ensure that the array is done, I’ve put this code in End of Experiment:

del rankall[:2]

with that code I get 18 of the 22 items instead of 20 of 22.

if I use:

del rankall[:1]

I get 21 of the 22 items.

I’ve tried the same code with [0:1] and [0,1], but those don’t work consistently either.

I have another array where I just need to cut out the first item. For that I used the following code in the End Experiment tab:

del PlanTimeArr[0]

That also does not work consistently. Sometimes it cuts one item, sometimes it cuts 2.

What am I doing wrong?

Thank you for your help.

Just tried

rankall.pop(1)
rankall.pop(0)

That deleted 4 items so I get 18 of 22 instead of 20 of 22

And, tried this:

PlanTimeArr = PlanTimeArr+[PlanTime]
PlanTimeArr.pop(0)

But, that deletes 2 items.

I was thinking that because rank all pushes into the array as pairs, 1 item deletes 2, but plantimearr does not push in as pairs and 0 is still deleting 2. So, I think it must be something earlier in the routine that is the problem, but I don’t know what to look for.

Any suggestions are greatly appreciated.

Solved: Moved the code to the End Experiment tab of the final routine (when I posted it was in the End Experiment tab of the looped routine where the array data was being collected) and now it works as it is supposed to.