I need someone to help with an explanation of ValueError and TypeError. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need someone to help with an explanation of ValueError and TypeError.

2nd Jun 2020, 10:56 AM
Shobande Mayowa
3 Answers
+ 13
A TypeError occurs when an operation or function is applied to an object of inappropriate type. A ValueError occurs when a built-in operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError. Examples: passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError.
2nd Jun 2020, 11:36 AM
Killú
Killú - avatar
+ 5
Just a quick refresher from the Python course lesson (second tab): https://www.sololearn.com/learn/Python/2440/
2nd Jun 2020, 11:42 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
Thanks y'all... I understand it now.
2nd Jun 2020, 12:26 PM
Shobande Mayowa