Python Forum

Full Version: which exception should be thrown for a sequence of the wrong length?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
which exception should be thrown for the case of passing, to a function, a sequence of the wrong length? TypeError and ValueError both seem wrong and there is no LengthError.
ValueError, because there is an error with the value, wrong length, not the type.

You can make your own exception classes.