In this example:
x = int(input("x: "))
print(f'x = {x}')if the input is a string, a ValueError is raised. Why not a TypeError? An invalid data type is inputted after all.
Explain Python ValueError Exception Handling (With Real Examples & Best Practices)
What's the difference between a TypeError and ValueError?
422 error.
What does this error mean:"value too long for type character varying(25)"
When you define a model with a charfield, this one have a max_length option. Here, it's certainly 25 characters. So you can't send a value with more than 25 characters.
More on reddit.comWhat are common Python errors?
How do I handle errors in Python?
How can I monitor Python errors in real time?
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.
Cite
ValueError a function is called on a value of the correct type, but with an inappropriate value
TypeError : a function is called on a value of an inappropriate type