Lastly, what if the array given to average is something like ["cat", "dog", "rabbit"]? There is no such thing as an average of three words, and so the correct behavior might be to produce an error that says something like The array must have only numbers.. Instead, because the program does not verify that the list only contains numbers, it would produce no failure, just returning the number 1. And if we fixed the defect above, we would get the (confusing) error TypeError: unsupported operand type(s) for Div on the last line, because the + in Python, in addition to computing addition, also concatenates strings, so the last line would compute "0catdograbbit" / 3.
The error would actually be "TypeError: unsupported operand type(s) for +: 'int' and 'str' on line 4" because Python cannot handle + between an int and a str.
Where: https://criticallyconsciouscomputing.org/verification
This paragraph is incorrect:
The error would actually be "TypeError: unsupported operand type(s) for +: 'int' and 'str' on line 4" because Python cannot handle + between an int and a str.