Mar-01-2019, 05:36 AM
Hello,
Whenever I call list() on a permutations object it removes all of the data from the permutations object. Could anyone explain why that is to me?
Example 1:
Whenever I call list() on a permutations object it removes all of the data from the permutations object. Could anyone explain why that is to me?
Example 1:
1 2 3 4 5 6 7 8 |
from itertools import permutations perm = permutations([ 1 , 2 , 3 ]) print ( list (perm)) print ( len ( list (perm))) |
Output:[(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]
0
Example 2:1 2 3 4 5 6 7 8 |
from itertools import permutations perm = permutations([ 1 , 2 , 3 ]) print ( len ( list (perm))) print ( list (perm)) |
Output:6
[]