import random


def nullify(val, probability=0.1):
    """Function that randomly sets value to null with specified probality.

    Parameters
    ----------
    val : any
        Original value
    probality : float
        Probability with which the value will be set to None.
        Must be in the range [0, 1]. Default: 0.1

    Returns
    -------
    any or None
    """

    if probability <= 0:
        return val
    elif probability >= 1:
        return None
    random_draw = random.random()
    return None if random_draw < probability else val