import random


def weighted_choice(choices):
    """
    Pick a weighted value off

    :param list choices: Each item is a tuple of choice and weight
    :return:
    """

    total = sum(weight for choice, weight in choices)
    selection = random.uniform(0, total)
    counter = 0
    for choice, weight in choices:
        if counter + weight > selection:
            return choice
        counter += weight
    assert False, "Shouldn't get here"