FunctionRacerProblemsRace

Names to Numbers

Beginnerscikit-learnPython

Models need numbers, not names. Return labels with each name replaced by a code: 0 for the alphabetically first name, 1 for the next, and so on.

Example 1

labels ["red","green","red","blue"]
returns [2,1,2,0]

Alphabetically: blue is 0, green is 1, red is 2.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More scikit-learn problems