Just to make things clear. input("x: ") always returns a string. It can be "123" or "bananas". In the first case, it can be converted to an integer. In the second case, it cannot, and a ValueError is raised. But in either case the type is fine for the int function. So this is a value error, not a type error. Answer from ploud1 on reddit.com
🌐
Python
docs.python.org β€Ί 3 β€Ί library β€Ί exceptions.html
Built-in Exceptions β€” Python 3.14.3 documentation
The BaseExceptionGroup constructor returns an ExceptionGroup rather than a BaseExceptionGroup if all contained exceptions are Exception instances, so it can be used to make the selection automatic. The ExceptionGroup constructor, on the other hand, raises a TypeError if any contained exception ...
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί handling-typeerror-exception-in-python
Handling TypeError Exception in Python - GeeksforGeeks
August 22, 2025 - Trying to use a variable like a string or number as if it were a function will raise a TypeError. ... To fix this error, just print the variable without parentheses. ... Python list indices must be integers or slices.
🌐
W3Schools
w3schools.com β€Ί python β€Ί ref_exception_typeerror.asp
Python TypeError Exception
Python Examples Python Compiler ... Certificate Python Training ... The TypeError exception occurs if an operation tries to perform an action with an unexpected data type....
🌐
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.

🌐
Pynerds
pynerds.com β€Ί typeerror-exception-in-python
TypeError Exception in Python
TypeError exceptions occur on an attempt to perform an operation on objects of an inappropriate/unsupported type. This typically occurs when attemptin
🌐
Real Python
realpython.com β€Ί ref β€Ί builtin-exceptions β€Ί typeerror
TypeError | Python’s Built-in Exceptions – Real Python
March 27, 2025 - TypeError is a built-in exception that occurs when an operation is applied to an object of inappropriate type.
Find elsewhere
🌐
EDUCBA
educba.com β€Ί home β€Ί software development β€Ί software development tutorials β€Ί python tutorial β€Ί python typeerror
Python TypeError | How to Avoid TypeError with Examples
April 13, 2023 - TypeError is a kind of error that python generates. We are trying to perform the operation of the wrong type of object. For example, if we are trying to do the square root of a number but we are passing a list instead of int, then TypeError ...
Call Β  +917738666252
Address Β  Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Rollbar
rollbar.com β€Ί home β€Ί how to fix typeerror exceptions in python
How to Fix TypeError Exceptions in Python | Rollbar
October 1, 2022 - The Python TypeError is an exception that occurs when the data type of an object in an operation is inappropriate. This can happen when an operation is performed on an object of an incorrect type, or it is not supported for the object.
🌐
Qodo
qodo.ai β€Ί blog β€Ί learn β€Ί common python error types and how to resolve them
Common Python error types and how to resolve them
March 20, 2025 - BaseException β”œβ”€β”€ Exception β”‚ β”œβ”€β”€ ArithmeticError β”‚ β”‚ β”œβ”€β”€ FloatingPointError β”‚ β”‚ β”œβ”€β”€ OverflowError β”‚ β”‚ └── ZeroDivisionError β”‚ β”œβ”€β”€ AttributeError β”‚ β”œβ”€β”€ ImportError β”‚ β”‚ └── ModuleNotFoundError β”‚ β”œβ”€β”€ LookupError β”‚ β”‚ β”œβ”€β”€ IndexError β”‚ β”‚ └── KeyError β”‚ β”œβ”€β”€ NameError β”‚ β”‚ └── UnboundLocalError β”‚ β”œβ”€β”€ OSError β”‚ β”‚ β”œβ”€β”€ FileNotFoundError β”‚ β”‚ β”œβ”€β”€ ConnectionError β”‚ β”‚ └── PermissionError β”‚ β”œβ”€β”€ TypeError β”‚ └── ValueError └── SystemExit Β· Knowing how to interpret and fix these issues efficiently can save hours of debugging time down the road and prevent production issues before they occur. Let’s explore the most common error types you’ll encounter in Python and learn how to handle them with finesse.
🌐
Python documentation
docs.python.org β€Ί 3 β€Ί tutorial β€Ί errors.html
8. Errors and Exceptions β€” Python 3.14.3 documentation
>>> def divide(x, y): ... try: ... result = x / y ... except ZeroDivisionError: ... print("division by zero!") ... else: ... print("result is", result) ... finally: ... print("executing finally clause") ... >>> divide(2, 1) result is 2.0 executing finally clause >>> divide(2, 0) division by zero! executing finally clause >>> divide("2", "1") executing finally clause Traceback (most recent call last): File "<stdin>", line 1, in <module> divide("2", "1") ~~~~~~^^^^^^^^^^ File "<stdin>", line 3, in divide result = x / y ~~^~~ TypeError: unsupported operand type(s) for /: 'str' and 'str'
🌐
DataCamp
datacamp.com β€Ί tutorial β€Ί exception-handling-python
Exception & Error Handling in Python | Tutorial by DataCamp | DataCamp
December 12, 2024 - Yes, Python allows you to catch multiple exceptions in a single try-except block by using a tuple of exception types. For example: except (TypeError, ValueError):. This will handle either a TypeError or a ValueError in the same block.
🌐
PythonForBeginners.com
pythonforbeginners.com β€Ί home β€Ί typeerror in python
TypeError in Python - PythonForBeginners.com
December 28, 2022 - TypeError is an exception in Python programming language that occurs when the data type of objects in an operation is inappropriate. For example, If you attempt to divide an integer with a string, the data types of the integer and the string object will not be compatible.
🌐
Pronod's Blog
data-intelligence.hashnode.dev β€Ί handling-typeerror-in-python-guide
Understanding and Fixing Python TypeErrors
September 13, 2024 - In Python, a TypeError is a built-in exception that occurs when an operation or function is applied to an object of inappropriate data type. This error arises when Python cannot handle the combination of types being used.
🌐
Cornell Computer Science
cs.cornell.edu β€Ί courses β€Ί cs1110 β€Ί 2024fa β€Ί lectures β€Ί lecture24 β€Ί handout-24.pdf pdf
11/17/24 1 Error Types in Python def foo(): assert 1 == 2, 'My error' …
Creating Errors in Python Β· def foo(x): assert x < 2, 'My error' … Β· def foo(x): if x >= 2: m = 'My error' err = AssertionError(m) raise err Β· β€’ Create errors with raise Β· Β§ Usage: raise <exp> Β§ exp evaluates to an object Β· Β§ An instance of Exception Β· β€’ Tailor your error types Β· Β§ ValueError: Bad value Β· Β§ TypeError: Bad type Β·
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί built-exceptions-python
Python Built-in Exceptions - GeeksforGeeks
2 weeks ago - Python provides a set of built-in exceptions, each designed to signal a specific type of error and help you debug more effectively.
🌐
Rollbar
rollbar.com β€Ί home β€Ί what are the different types of python errors? – and how to handle them
What are the Different Types of Python Errors? – and How to Handle Them
July 14, 2025 - In Python, a TypeError occurs when you try to perform an operation on incompatible data types. This often happens when mixing strings and numbers, or passing the wrong type of argument to a function.
🌐
Carleton University
cs.carleton.edu β€Ί cs_comps β€Ί 1213 β€Ί pylearn β€Ί final_results β€Ί encyclopedia β€Ί typeError.html
Error Encyclopedia | Type Error
For example, the multiplication ... 1187228.3001583007 * 7 8310598.101108105 Β· A TypeError occurs in Python when you attempt to call a function or use an operator on something of the incorrect type....
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.