def only_choice(values):
    "Apply the only choice strategy to a Sudoku puzzle\n\n    The only choice strategy says that if only one box in a unit allows a certain\n    digit, then that box must be assigned that digit.\n\n    Parameters\n    ----------\n    values(dict)\n        a dictionary of the form {'box_name': '123456789', ...}\n\n    Returns\n    -------\n    dict\n        The values dictionary with all single-valued boxes assigned\n\n    Notes\n    -----\n    You should be able to complete this function by copying your code from the classroom\n    "
    for unit in unitlist:
        for digit in '123456789':
            dplaces = [box for box in unit if (digit in values[box])]
            if (len(dplaces) == 1):
                values[dplaces[0]] = digit
    return values
Apply the only choice strategy to a Sudoku puzzle

The only choice strategy says that if only one box in a unit allows a certain
digit, then that box must be assigned that digit.

Parameters
----------
values(dict)
    a dictionary of the form {'box_name': '123456789', ...}

Returns
-------
dict
    The values dictionary with all single-valued boxes assigned

Notes
-----
You should be able to complete this function by copying your code from the classroom
def only_choice(values):
    "Apply the only choice strategy to a Sudoku puzzle\n\n    The only choice strategy says that if only one box in a unit allows a certain\n    digit, then that box must be assigned that digit.\n\n    Parameters\n    ----------\n    values(dict)\n        a dictionary of the form {'box_name': '123456789', ...}\n\n    Returns\n    -------\n    dict\n        The values dictionary with all single-valued boxes assigned\n\n    Notes\n    -----\n    You should be able to complete this function by copying your code from the classroom\n    "
    for unit in unitlist:
        for digit in '123456789':
            dplaces = [box for box in unit if (digit in values[box])]
            if (len(dplaces) == 1):
                values[dplaces[0]] = digit
    return values