Blue Week Special Offer | Brighten your week!

Maybe worth re-working some of the wording here

Screen Link:

The Code:

if len(unique_targets) == 1:
        # Insert code here that assigns the "label" field to the nodes list
        if len(unique_targets) == 1:
        if 0 in unique_targets:
            tree["label"] = 0
        elif 1 in unique_targets:
            tree["label"] = 1

I just stared at this for quite a while wondering what was going on, and maybe I’m just the only one, but I feel like it’s because it’s really unclear what is being asked for here. The code above is the correct code from “Show me the answer” - but you can see that it’s asking us to assign the “label” field to the nodes list.

There is literally a variable outside of this function called nodes that is a list. I couldn’t for the life of me figure out what I was meant to do here because there is code above this that is iteratively adding the length of that list + 1 to itself in every loop.

If it’s asking us to do something with a dictionary I think that should be more clear. Maybe I just blanked and wasn’t thinking about labels in the right way here, but it could at the very least say to assign the appropriate value for the label key or something.

Not a huge deal, just thought I would point out that I found it somewhat confusing!

EDIT: Alright, the second half of this screen is the same problem.

    # Insert code here that assigns the "column" and "median" fields to the nodes list
    tree["column"] = best_column
    tree["median"] = column_median

What the heck is the nodes list? It’s a dictionary! Fields? If we’ve spent this time learning about Python and proper language for the component parts of a dictionary, those words should be used.