I’ve been looking for an efficient Python code to generate 10 character alphanumeric strings. The string should start from “AA0AA0000A” and should increase the sequence from right to left
The code I've tried:
import string
from itertools import permutations as p
alpha = string.ascii_uppercase
num = string.digits
for a, b in p(alpha, 2):
for c in p(num, 1):
for d, e in p(alpha, 2):
for f, g, h, i in p(num, 4):
for j in p(alpha, 1):
print(a, b, c, d, e, f, g, h, i, j)
and the output sample I got:
A B ('0',) A B 0 1 2 3 ('A',)
A B ('0',) A B 0 1 2 3 ('B',)
A B ('0',) A B 0 1 2 3 ('C',)
But the output I expect is like
A A 0 A A 0 0 0 0 A
A A 0 A A 0 0 0 0 B
A A 0 A A 0 0 0 0 C
Is there a better or efficient way to generate the sequence of strings?