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

Answer from David on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › what's the difference between a typeerror and valueerror?
r/learnpython on Reddit: What's the difference between a TypeError and ValueError?
September 21, 2022 -

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.

Discussions

Value error, name error, type error?
if you try to execute the statement int('a'), Python will throw a ValueError ('a' is not appropriate for converting into an integer). TypeError refers to a mismatch in types. (Types are the "kinds" of values, e.g. More on teamtreehouse.com
🌐 teamtreehouse.com
1
September 22, 2018
ValueError vs TypeError
Eva Feng is having issues with: I find it a bit confusing to distinguish between ValueError and TypeError. For example, when you have float( a string ) - it shows up as ValueEr... More on ecs.teamtreehouse.com
🌐 ecs.teamtreehouse.com
1
February 26, 2026
ValueError vs TypeError
Eva Feng is having issues with: I find it a bit confusing to distinguish between ValueError and TypeError. For example, when you have float( a string ) - it shows up as ValueEr... More on teamtreehouse.com
🌐 teamtreehouse.com
1
February 26, 2026
python - ValueError Versus TypeError, Why? - Stack Overflow
The Error output: "ValueError: invalid literal for int() with base 10: 'yes'" I know it is obvious that I AM WRONG, but I do not understand why. When I try to convert a string to an int, I More on stackoverflow.com
🌐 stackoverflow.com
People also ask

What is the difference between a TypeError and a ValueError?
A TypeError happens when you use the wrong type (like adding a string to a number), while a ValueError happens when the type is right but the value is incorrect (like converting “abc” to an integer).
🌐
middleware.io
middleware.io › blog › python-error-types
Python Error Types: Common Errors and How to Handle Them
How do I handle errors in Python?
You should use the try-except blocks and write clear error messages.
🌐
middleware.io
middleware.io › blog › python-error-types
Python Error Types: Common Errors and How to Handle Them
What are common Python errors?
The most common Python errors consist of SyntaxError, NameError, TypeError, ValueError, IndexError, KeyError, and AttributeError.
🌐
middleware.io
middleware.io › blog › python-error-types
Python Error Types: Common Errors and How to Handle Them
Top answer
1 of 2
8
@Liam Hayes (https://teamtreehouse.com/liamhayes) Hi! I have a note about @Steven Parker (https://teamtreehouse.com/stevenparker)'s example (especially the second one). When I was trying to wrap my head around this, I could not for the life of me understand why the built-in function for changing something to an int would give a ValueError with a string as opposed to a TypeError. Surely, it's expecting a number, right? Well, no. It isn't. The int() function takes either a number or a string. It can convert the string "21" to the integer 21, but it can't convert "dog" to a number. Thus, it's getting the right type, but it's still not a value that it can convert. This is when we get the ValueError. It's of the right type, but the value is such that it still can't be done. That being said, if we tried to send in something that was neither a string nor a number, it would have generated a TypeError as it is of the wrong type. Hope this helps! :sparkles: edited for additional note In your own custom made functions, you can pass in whatever you want, although ideally, you know what you're passing in. This is not true of built-in functions in Python. When in doubt, check the documentation for the function in question.
2 of 2
0
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. For more details, see the Exceptions page (https://docs.python.org/3/library/exceptions.html) of the Python documentation.
🌐
Quora
quora.com › What-is-the-difference-between-TypeError-and-ValueError-in-Python-When-does-Python-throw-these-exceptions
What is the difference between 'TypeError' and 'ValueError' in Python? When does Python throw these exceptions? - Quora
Answer: 🔴1. TypeError happens when an operation is performed on an inappropriate type. For example: Copy [code]result = 'string' + 5 # Can't add string and integer [/code]🔴2. ValueError occurs when a function gets an argument of the right type but inappropriate value. For instance: Copy [co...
🌐
YouTube
youtube.com › watch
ValueErrors & TypeErrors in Python | How to tell them apart! - YouTube
Here's how to tell the difference between TypeErrors and ValueErrors in Python.My Full OOP Course:https://www.udemy.com/course/object-oriented-programming-in...
Published: March 28, 2025
🌐
Middleware
middleware.io › blog › python-error-types
Python Error Types: Common Errors and How to Handle Them
A TypeError happens when you use the wrong type (like adding a string to a number), while a ValueError happens when the type is right but the value is incorrect (like converting “abc” to an integer).
Find elsewhere
🌐
Real Python
realpython.com › ref › builtin-exceptions › valueerror
ValueError | Python’s Built-in Exceptions – Real Python
ValueError is a built-in exception that gets raised when a function or operation receives an argument of the correct type, but its actual value isn’t acceptable for the operation at hand, and no more specific exception, such as IndexError, describes the situation.
🌐
Carleton University
cs.carleton.edu › cs_comps › 1213 › pylearn › final_results › encyclopedia › valueError.html
Error Encyclopedia | Value Error
To encounter a ValueError in Python means that is a problem with the content of the object you tried to assign the value to. This is not to be confused with types in Python. For instance, imagine you have a dog and you try to put it in a fish tank. This would be an example of a type error, ...
🌐
Scaler
scaler.com › home › topics › python valueerror
Python ValueError - Scaler Topics
December 15, 2022 - A TypeError, as opposed to a ValueError, is raised when an operation is performed that uses an incorrect or unsupported object type. For example, consider our previous example, if you are trying to fit a TV in a phone box, then Python is smart enough to know that these two types do not match.
🌐
Sololearn
sololearn.com › en › Discuss › 2497149 › what-is-the-difference-between-typeerror-and-valueerror
What is the difference between 'TypeError' and 'ValueError'? | Sololearn: Learn to code for FREE!
A Value error is Raised when a ... (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 ...
🌐
Iditect
iditect.com › faq › python › valueerror-and-typeerror-in-python.html
ValueError and TypeError in python
ValueError: A ValueError is raised ... operation is not valid. ... In this example, the attempt to convert the string "abc" to an integer using int() raises a ValueError because the string cannot be converted to a valid integer....
🌐
Treehouse
ecs.teamtreehouse.com › community › valueerror-vs-typeerror
ValueError vs TypeError (Example) | Treehouse Community
February 26, 2026 - Eva Feng is having issues with: I find it a bit confusing to distinguish between ValueError and TypeError. For example, when you have float( a string ) - it shows up as ValueEr...
🌐
Sivo
hub.sivo.it.com › home › python exceptions › what is the difference between typeerror and valueerror in python?
What is the difference between TypeError and ValueError in Python? | Python Exceptions – Sivo
August 30, 2025 - # Example for `+` with a non-sequence and non-number: # frozenset + list -> TypeError: unsupported operand type(s) for +: 'frozenset' and 'list' A ValueError indicates that a function or operation received an argument of the correct data type, but the actual value of that argument is inappropriate or out of bounds for what the operation expects.
🌐
Python Forum
python-forum.io › thread-28486.html
Type Error or Value Error?
print(int('100.0'))it is type error, how is it value error?
🌐
Turing
turing.com › kb › valueerror-in-python-and-how-to-fix
What is ValueError in Python & How to fix it
Example-1: Handle the ValueError for incorrect data · The script below should be placed in a Python file to collect the user's age value. The try block will throw the ValueError exception and output the custom error message if the user enters a non-numeric value for the age field.