O'Reilly logo
  • Majid Hussain thinks this is interesting:

colors[:len(np.unique(y))

Note

This will pick up the first 2 colors in the list of colors as there are only 2 unique values in y.