The code:
import random
x = ['A','B','C','D','E','F',
'G','H','I','J','K','L',
'M','N','O','P','Q','R',
'S','T','U','V','W','X',
'Y','Z']
y1 = random.sample(x, 2)
y2 = random.sample(x, 2)
y3 = random.sample(x, 2)
y4 = random.sample(x, 2)
y5 = random.sample(x, 2)
Query
As shown above, I select 5 random combinations of patterns and declare them under variables y'x'.
To improve my code, I would like to do this, but make sure that the element from the list does not appear more than once in all variable outputs, in which all combinations are different and not repeated. I would prefer to achieve this without removing items from the list, as it is reused later in the code.
Expected Result (Example):
>>> y1
['A', 'Q']
>>> y2
['E', 'K']
>>> y3
['C', 'O']
>>> y4
['Z', 'X']
>>> y5
['P', 'L']