[Solved] list of random codes like this : (XXXXX-XXXXX-XXXXX) on python


from random import choice
from string import ascii_uppercase, digits

CHAR_SET = ascii_uppercase + digits


def get_integer(msg):
    while True:
        try:
            return int(input(msg))
        except ValueError:
            pass


def get_random_code(chunks=3, delim='-'):
    def get_random_str(length=5):
        return ''.join(choice(CHAR_SET) for _ in range(length))
    return delim.join(get_random_str() for _ in range(chunks))


if __name__ == '__main__':
    total_combos = get_integer('Enter # of combos to generate: ')
    for _ in range(total_combos):
        print(get_random_code())

5

solved list of random codes like this : (XXXXX-XXXXX-XXXXX) on python