+ 1

What is the difference between 'TypeError' and 'ValueError'?

15th Sep 2020, 1:55 AM
Name
Name - avatar
2 odpowiedzi
+ 4
A Value error is Raised when a built-in operation or function receives an argument that has the right type but an inappropriate value the float function can take a string, ie float('5'), it's just that the value 'string' in float('string') is an inappropriate (non-convertible) string On the other hand, Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError so you would get a TypeError if you tried float(['5']) because a list can never be converted into a float
15th Sep 2020, 2:02 AM
Shubham Ingale
Shubham Ingale - avatar
0
Thanks Sir
15th Sep 2020, 2:14 AM
Name
Name - avatar