Python Forum
Python Forum
>
Python Coding
>
General Coding Help
> which exception should be thrown for a sequence of the wrong length?
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.
Skaperen
Jan-06-2023, 03:34 AM
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.
deanhystad
Jan-06-2023, 04:13 AM
ValueError, because there is an error with the value, wrong length, not the type.
You can make your own exception classes.
Python Forum
>
Python Coding
>
General Coding Help
> which exception should be thrown for a sequence of the wrong length?