Randomisation of stimuli so that all stimuli are paired at least once

I am trying to create an experiment with a series of different luminance levels. Currently, I am using simple images set at different Lum levels (0,60,120,180,240).

I plan to have each image appear, with all levels paired within each run of the experiment while I record the pupil response. How do I get psychopy to both randomise the sequence, but also loop until all levels have been paired?

Thanks in advance!

This sounds like a candidate for my independent randomisation demo but please could you clarify the numbers involved?

Do you want x images times x-1 second images with independent allocation to 5 x 5 luminosities?