No Doubles check in lists??

Hi. I’m working on a script which picks 5 random integers out of 20 and put them in a list.
I want to check that every picked integer is not already existing in the list. So -No Doubles-!

How can you say in applescript something like:

"this 4th random picked integer is the same as the 2nd picked integer in the list, So…go back and pick an other random integer and check if this one is not equal to the 1st, 2nd and 3thd integers of this list.

Hope somebody have any comments :smiley:

THANKS!

You may be looking for “is in”. Eg:

set finalList to {}
repeat
	set rn to random number from 1 to 20
	if rn is not in finalList then set finalList's end to rn
	if (count finalList) is 4 then exit repeat
end repeat

finalList

Hmmm Yes. That works very nice.

Thanks a lot!