When I create the permutations below, there are 360 possibilities.
#Print permutations of 1 to 6 of a size 4
from itertools import permutations
possibilities = permutations([1,2,3,4,5,6], 4) #Permutations of size 6
sum_of_possibilities = 0
for i in list(possibilities):
print(i)
sum_of_possibilities = sum_of_possibilities +1
I would like to get 4 random permutations of these 360 and save each number in a different variable.
For examples:
Select these 4 permutations below
(3, 5, 6, 2)
(1, 6, 4, 3)
(4, 3, 1, 5)
(6, 5, 3, 4)
and save the first number 3 as x1; 5 as x2; 6 as x3; 2 as x4... 3 as x15 and 4 as x16.
#RESULTS
print(f'Total of possibilities are: {sum_of_possibilities}')
print(possibilities[0])
Total of possibilities are: 360
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_13912\1726349991.py in <module>
3 print(f'Total of possibilities are: {sum_of_possibilities}')
4
----> 5 print(possibilities[0])
TypeError: 'itertools.permutations' object is not subscriptable
thisanswer your question?