import random


def ran_num(length=1):
    """
    Random string number generator.

    This function generates a string with a custom length
    that contains random digits and characters from a-f.

    Parameters:
        length: Number of places the number should have.

    Returns:
        A string with random digits and characters.
    """
    number = ''
    for z in range(length):
        r = random.randint(0, 15)
        if 0 <= r <= 9:
            number += str(r)
        elif r == 10:
            number += 'a'
        elif r == 11:
            number += 'b'
        elif r == 12:
            number += 'c'
        elif r == 13:
            number += 'd'
        elif random == 14:
            number += 'e'
        elif r == 15:
            number += 'f'
    return number