Python Forum
Calling list() on permutation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling list() on permutation
#1
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:
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:
from itertools import permutations


perm = permutations([1,2,3])

print(len(list(perm)))

print(list(perm))
Output:
6 []
Reply


Messages In This Thread
Calling list() on permutation - by trevorkavanaugh - Mar-01-2019, 05:36 AM
RE: Calling list() on permutation - by ichabod801 - Mar-01-2019, 05:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to print each possible permutation in a dictionary that has arrays as values? noahverner1995 2 1,773 Dec-27-2021, 03:43 AM
Last Post: noahverner1995
  Even/Odd permutation braankoo 9 11,687 Jan-10-2021, 01:19 AM
Last Post: Larz60+
  Help with calling list from user input farispython 5 2,858 Nov-03-2019, 03:13 PM
Last Post: Gribouillis
  memory error using permutation list of 11 elements kikidog 1 3,916 Sep-10-2019, 08:22 PM
Last Post: ichabod801
  how to get all the possible permutation and combination of a sentence in python sodmzs 1 4,190 Jun-13-2019, 07:02 AM
Last Post: perfringo
  Permutation help. jarrod0987 1 2,203 Jun-28-2018, 04:44 PM
Last Post: ichabod801
  Calling list from previous function zykbee 1 2,973 Nov-13-2017, 12:10 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020