Generate all base 26 triplets in the fastest way

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

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

What is the fastest way to do this in python?

+4
source share
1 answer
 >>> from itertools import product >>> from string import ascii_uppercase >>> triplets = map(''.join, product(ascii_uppercase, repeat=3)) >>> triplets[4] 'AAE' 
+5
source

Source: https://habr.com/ru/post/1485384/


All Articles