import random, string variable = ''.join(random.SystemRandom().choice(string.ascii_letters) for _ in range(15)) ## the number you want cod = f"{variable} = 'text example' print(variable, ':', {variable})" exec(cod)