I would like to create a set of identities using all combinations of three uppercase letters while avoiding for
loops to save computation time. I would like to have identities that range from ID_AAA
to ID_ZZZ
.
I can do this using for
loops:
> from string import ascii_uppercase
> IDs = []
> for id_first_letter in ascii_uppercase:
> for id_second_letter in ascii_uppercase:
> for id_third_letter in ascii_uppercase:
> IDs.append('ID_' + id_first_letter + id_second_letter + id_third_letter)
But of course I would like to simplify the code here. I have tried to use the map
function but the best I could come up with was this:
> from string import ascii_uppercase
> IDs = list(map(lambda x,y,z: 'ID_' + x + y + z,ascii_uppercase,ascii_uppercase,ascii_uppercase))
This is iterating among all letters at the same time, so I can only get ID_AAA
, ID_BBB
, ..., ID_ZZZ
. All three letters are always the same as a consequence. Can I fine-tune this approach in order to iterate one letter at a time or do I need to use a totally different approach?