Skeleton: Efficiently generate a random string of n digits

Written by Python, Skeleton

import random


def generate(n):
    output = str(random.randrange(10 ** (n - 1), 10 ** n))
    return output


def run():
    # Number of digits (i.e. a 10-digit string)
    n = 10
    print(generate(n))


if __name__ == '__main__':
    run()