Learn practical skills, build real-world projects, and advance your career
from __future__ import print_function
training_data = [
    ['Green', 3, 'Apple'],
    ['Yellow', 3, 'Apple'],
    ['Red', 1, 'Grape'],
    ['Red', 1, 'Grape'],
    ['Yellow', 3, 'Lemon'],
]
#training_data
# Column labels.
# These are used only to print the tree.
header = ["color", "diameter", "label"]
def unique_vals(rows, col):
#Find the unique values for a column in a dataset.
    return set([row[col] for row in rows])
# Demo:
print(unique_vals(training_data, 0))
unique_vals(training_data, 1)
#######
{'Yellow', 'Red', 'Green'}
{1, 3}