import random
import string


def create_rand_text(length, max_len=None):
    """
    create random text for a specific length,
    if max_len is specified creates a random piece of text
    which is of a random length between length and max_len
    """
    if max_len is not None:
        length = random.randint(length, max_len)

    to_ret_string = ""

    for _ in range(length):
        to_ret_string += random.choice(string.printable)

    return to_ret_string