import random


def assign_label(label_list):
    """Given the current label list finds a value not in the list,
        adds the value to the list and returns it."""
    # very simplistic algorithm, not good when lots of labels.
    if not label_list:
        new_label = random.randint(1, 1000)
    else:
        new_label = random.randint(1, 1000)
        while new_label in label_list:
            new_label = random.randint(1, 1000)
    label_list.append(new_label)
    return new_label