| Reference | Downloads | Github

Participant number cannot be used more than once

I have made a variable with the participant numbers that have been used:

thisExp.addData(‘partNumbersUsed’, expInfo[‘participantnr’])

What would a code be to make sure that the number can only be used once?
something like this:
If name not in partNumbersUsed => continue
Else => Choose another name

Thank you in advance,

If you will test all subjects during one run of the experiment, then you could use a subject loop. Otherwise you will need to keep some ‘state’ of used subject numbers. This means a file with ‘used numbers’ or what I do is something like:

type or paste code here
```## get unique data outfile name and log some stuff
while ( os.access(the_ofilename, os.F_OK) ):
print("using " + the_ofilename )

outfile = open(the_ofilename,'a+');
outfile.write('  '+ str(the_ofilename) + '\n')

to check for existing used numbers and go 1 number higher. However, if you delete a file, ( e.g., you have tested subject 00 through 10, put you delete 08 because it was a dud), 08 will get reused.