Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
which itertools method
#2
import itertools

result = (itertools.product('AB', repeat=2))
result = map(''.join, result)
print(list(result))

result = (itertools.product('ABC', repeat=3))
result = map(''.join, result)
print(list(result))
Output:
['AA', 'AB', 'BA', 'BB'] ['AAA', 'AAB', 'AAC', 'ABA', 'ABB', 'ABC', 'ACA', 'ACB', 'ACC', 'BAA', 'BAB', 'BAC', 'BBA', 'BBB', 'BBC', 'BCA', 'BCB', 'BCC', 'CAA', 'CAB', 'CAC', 'CBA', 'CBB', 'CBC', 'CCA', 'CCB', 'CCC']
Reply


Messages In This Thread
which itertools method - by Skaperen - May-10-2020, 10:29 PM
RE: which itertools method - by Yoriz - May-10-2020, 10:45 PM
RE: which itertools method - by Skaperen - May-13-2020, 12:13 AM

Forum Jump:

User Panel Messages

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