Improve error messages for invalid color input in resistor-color (Python)

In the Python resistor-color exercise, providing an invalid color currently
results in a generic error that may be confusing for beginners.

I’d like to propose explicitly validating the input and raising a ValueError
with a clear message, for example:

ValueError: Invalid color: pink

This would improve learner feedback without changing the exercise intent
or expected behavior.

If this approach sounds reasonable, I’d be happy to open a PR to implement it.

The resistor color exercise doesn’t test for an invalid color anywhere that I can see. Where do you see that test?

Hi @deekshahavaragi :wave:

Welcome to the Exercism forums!

None of the resistor-color exercises (resistor-color, resistor-color-duo, resistor-color-trio, resistor-color-expert) AFAK have test cases that test for invalid inputs, nor do any of those exercises ask the student to do input validation or error handling.

The error thrown is likely generic because it is coming from the Python runtime and not student code or expected results in test cases.

We’re not interested in adding error handling or input validation cases to these exercises at this time, as we have a general-ish policy to not require input validation for practice exercises unless the exercise itself is focused on input validation or error handling (or needs it for some structural reason).

There are exceptions to this policy (and the amount of them varies by programming language track), but for the most part we like to keep the practice exercises away from those sorts of tests.

If the student or the mentor would like to practice either input validation or error handling – they are free to do so by adding additional test cases locally.

Finally, the resistor-color exercises on the Python track pull from a common problem-specifications repo that is shared by all programming language tracks on Exercism. So if you’d like to discuss adding test cases or otherwise modifying the exercises, it should happen in the more generic Exercism category, and not here in Python.