Hi,

I'm really new to python and I've been working with some code that was given to me to create a study. There's one aspect about the code I'm not understanding, though. I don't understand why, in the section below "initialize list for hard coding..." the lists seem to be so long and in a certain pattern when the items are getting randomly shuffled later anyways. The reason I ask is because I want to add a third SOA time. So, if there is a good reason the lists are set up this way, how would I include a third SOA time?

Thanks in advance for your help

Posted below is the main body of the code

Code:
#define stimuli
#if using fullscreen the position values need to be changed and line width can be smaller
fixstim='+'
fixation=visual.TextStim(win,pos=(0,0),height=60,color=(1,1,1),text=fixstim)
rightlandmark=visual.Circle(win,units='pix',pos=(250,0),radius=30,edges=50,lineColor='LawnGreen',lineWidth=4)
leftlandmark=visual.Circle(win,units='pix',pos=(-250,0),radius=30,edges=50,lineColor='LawnGreen',lineWidth=4)
righttarg=visual.Circle(win,units='pix',pos=(250,0),radius=18,edges=50,lineColor='red',fillColor='red',lineWidth=4)
lefttarg=visual.Circle(win,units='pix',pos=(-250,0),radius=18,edges=50,lineColor='red',fillColor='red',lineWidth=4)
rightcue=visual.Circle(win,units='pix',pos=(250,0),radius=30,edges=50,lineColor='LawnGreen',lineWidth=12)
leftcue=visual.Circle(win,units='pix',pos=(-250,0),radius=30,edges=50,lineColor='LawnGreen',lineWidth=12)

#define stimulus duration times 
fixscreen_time=.8
cue_time=.15
soa_short=.05
soa_long=.15

#initialise lists for hard coding side, soa and validity proportions 
#cueside - 0=left; 1=right; soa - 0=early; 1=late; validity - 0=valid; 1=invalid

cueside=[0,0,1,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1,
0,0,1,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1,
0,0,1,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1,
0,0,1,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1,
0,0,1,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1,
0,0,1,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1,
0,0,1,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1]
soa=
[1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,1,0,1,0,
1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,1,0,1,0,
1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,1,0,1,0,
1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,1,0,1,0,
1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,1,0,1,0,
1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,1,0,1,0,
1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,0,0,1,1,0,1,0]
validity=[0,1,1,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1,
0,1,1,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1,
0,1,1,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1,
0,1,1,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1,
0,1,1,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1,
0,1,1,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1,
0,1,1,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,0,1,1]

#shuffle order of the trial factors
random.shuffle(cueside)
random.shuffle(soa)
random.shuffle(validity)

#define functions for components of trials
def fixscreen():
    fixation.draw()
    rightlandmark.draw()
    leftlandmark.draw()
    win.flip()
    core.wait(fixscreen_time)
    
def lcue():
    fixation.draw()
    rightlandmark.draw()
    leftcue.draw()
    win.flip()
    core.wait(cue_time)

def rcue():
    fixation.draw()
    leftlandmark.draw()
    rightcue.draw()
    win.flip()
    core.wait(cue_time)

def ltarg():
    fixation.draw()
    leftlandmark.draw()
    rightlandmark.draw()
    lefttarg.draw()
    win.flip()
        
def rtarg():
    fixation.draw()
    leftlandmark.draw()
    rightlandmark.draw()
    righttarg.draw()
    win.flip()
        
def short_soa():
    fixation.draw()
    leftlandmark.draw()
    rightlandmark.draw()
    win.flip()
    core.wait(soa_short)
    
def long_soa():
    fixation.draw()
    leftlandmark.draw()
    rightlandmark.draw()
    win.flip()
    core.wait(soa_long)
    
#instruction screen
instr1=visual.TextStim(win,height=35,color=(1,1,1),pos=(0,300),alignVert='center',alignHoriz='center',wrapWidth=1000,text="You will see a cross at the centre of the screen.")
instr2=visual.TextStim(win,height=35,color=(1,1,1),pos=(0,200),alignVert='center',alignHoriz='center',wrapWidth=1000,text="Try to keep looking at the cross.")
instr3=visual.TextStim(win,height=35,color=(1,1,1),pos=(0,100),alignVert='center',alignHoriz='center',wrapWidth=1000,text="One of the green circles to the left and right will get brighter.")
instr4=visual.TextStim(win,height=35,color=(1,1,1),pos=(0,0),alignVert='center',alignHoriz='center',wrapWidth=1000,text="A red circle will appear inside one of the green circles.")
instr5=visual.TextStim(win,height=35,color=(1,1,1),pos=(0,-100),alignVert='center',alignHoriz='center',wrapWidth=1000,text="Press the space bar when you see the red circle.")
instr6=visual.TextStim(win,height=35,color=(1,1,1),pos=(0,-200),alignVert='center',alignHoriz='center',wrapWidth=1000,text="Press the space bar to continue.")

instr1.draw()
instr2.draw()
instr3.draw()
instr4.draw()
instr5.draw()
instr6.draw()
win.flip()
keypress=event.waitKeys(keyList=["space","q"])
if keypress[0][0]=="q":
    core.quit()

#go through examples with the participant 
eg1=visual.TextStim(
    win, height=35, color=(1,1,1), pos=(0,-200), alignVert='center', 
    alignHoriz='center', wrapWidth=1000, 
    text="This is what the screen will look like."
)
eg1.draw()
fixation.draw()
leftlandmark.draw()
rightlandmark.draw()
win.flip()
event.waitKeys(keyList=['space'])

eg2=visual.TextStim(win,height=35,color=(1,1,1),pos=(0,-200),alignVert='center',alignHoriz='center',wrapWidth=1000,text="This is what a cue and target will look like.")
eg2.draw()
fixation.draw()
leftlandmark.draw()
rightcue.draw()
righttarg.draw()
win.flip()
event.waitKeys(keyList=['space'])

#first rating scale probe
ratingScale = visual.RatingScale(
    win, str('how happy do you feel right now?'),low=0, high=9, markerStart=4,
    acceptKeys='space')
while ratingScale.noResponse:
        ratingScale.draw()
        win.flip()

rating=ratingScale.getRating()
print(rating)

with open(filename, "a", newline = '\n') as dataFile:
    writer = csv.writer(dataFile)
    writer.writerow([str(startInfo[0]),str(startInfo[1]),str(startInfo[2]),str(startInfo[3]),str(''),str(''),str(''),str(''),str(''), rating])

#loop for trial sequence
for i in range (numtrials):
    fixscreen()
    if cueside[i]==0:
        lcue()
    else:
        rcue()
    if soa[i]==0:
        short_soa()
    else:
        long_soa()
    if validity[i]==0:
        ltarg()
    else:
        rtarg()
    RTClock=core.Clock()
    keypress=event.waitKeys(keyList=["space","q"])
    RT=RTClock.getTime()
    if keypress[0][0]=="q":
        core.quit()
    else:
        with open(filename, "a", newline='\n') as dataFile:
            writer=csv.writer(dataFile)
            writer.writerow([str(startInfo[0]),str(startInfo[1]),str(startInfo[2]),str(startInfo[3]),i,cueside[i],soa[i],validity[i],RT])

#close out data file and end experiment on a key press
dataFile.close()
thankyou=visual.TextStim(win,pos=(0,0),height=35,color=(1,1,1),text='Thank you for participating.')
thankyou.draw()
win.flip()
event.waitKeys()
core.quit()