Names to Numbers
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
1 <= len(labels) <= 60
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More scikit-learn problems
- Same ScaleBeginner
- Share RightBeginner
- Typical Squared MissBeginner
- What the Model LearnedBeginner
- Zero to OneBeginner
- Curves From LinesEasy
- Fill the HolesEasy
- Found and FlaggedEasy