4

I need to generate a list of triplets containing only uppercase English letters:

["AAA","AAB","AAC", ..., 'ZZZ']

What is the fastest way to do this in python?

mnowotka
  • 16,430
  • 18
  • 88
  • 134

1 Answers1

5
>>> from itertools import product
>>> from string import ascii_uppercase
>>> triplets = map(''.join, product(ascii_uppercase, repeat=3))
>>> triplets[4]
'AAE'
jamylak
  • 128,818
  • 30
  • 231
  • 230