random.choices & join functions

import random


def generateRandomString(length):
    chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

    return ''.join(random.choices(chars, k=length))


randomString = generateRandomString(10)
print(randomString)

Leave a Comment

Your email address will not be published. Required fields are marked *