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.


Hi Sean,

Don’t know if you are going to see this but I just had the exact same issue.

It would be really helpful for learners if the correct wording is presented in the comments as this will prevent too much time being spent while being led astray.

I must say though, I have mostly only encountered this problem in the machine learning courses so far. Everything else has been quite well written.


Glad I’m not alone on this!


Hi @peakelaw, @sean.d.workman,

Could you please share your feedback with the Content & Product teams of Dataquest? Just click the ? button in the upper-right corner of any screen of the Dataquest learning platform, select Share Feedback, fill in the form, and send it. Thanks!

1 Like