import random, string number = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(N)) ## "N" is the length of the text