import string
import random


def generate_uuid(length=4, characters=string.ascii_letters + string.digits):
    """Generate a string of random characters.

    Args:
        length (int, optional): The length of the UUID to generate.
        characters (string, optional): The character set used to build the UUID.

    Returns:
        string: A string representation of the generated UUID.
    """
    # Loop through a range defined by the length size
    # In each loop, make a random choice from our characters and append that to the uuid list
    uuid = []
    for _ in range(length):
        uuid.append(random.choice(characters))
    # Use join to convert the uuid list to a string
    return ''.join(uuid)