Introduction
When working with Python data-processing scripts, many developers encounter the error TypeError: unsupported operand type(s). This error usually appears when you try to perform an operation on two values that Python does not know how to combine.
In simple words, Python is telling you: “I cannot apply this operation to these data types.” In this article, you will learn what this error means, why it happens, and how to fix it using easy and practical examples.
What Does "Unsupported Operand" Mean in Python?
In Python, an operand is a value used in an operation. For example, in a + b, both a and b are operands, and + is the operator.
A TypeError: unsupported operand type(s) occurs when:
The operator is valid
But the data types of the operands are incompatible
Example:
result = 10 + "5"
Here, Python cannot add an integer and a string, so it raises a TypeError.
Common Error Message Formats
You may see the error in different forms, such as:
TypeError: unsupported operand type(s) for +: 'int' and 'str'TypeError: unsupported operand type(s) for -: 'list' and 'int'TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
The message clearly tells you which operator and data types caused the problem.
Mixing Different Data Types
The most common cause is mixing incompatible data types in an operation.
Example:
price = "100"
tax = 18
final_price = price + tax
Fix:
price = int(price)
final_price = price + tax
Always make sure operands are of compatible types before performing operations.
Performing Math Operations on Strings or Lists
Python does not allow mathematical operations on strings or lists in the same way as numbers.
Example:
total = [10, 20, 30] + 5
Fix:
total = sum([10, 20, 30]) + 5
In data processing scripts, always convert collections to numeric values when needed.
Using None Values in Calculations
Another very common reason is accidentally using None in calculations.
Example:
value = None
result = value + 10
Fix:
if value is not None:
result = value + 10
This often happens when a function does not return a value or data is missing.
Reading Data from Files or Databases
Data read from files, CSVs, or databases is often stored as strings.
Example:
age = row['age']
result = age + 5
Fix:
age = int(row['age'])
result = age + 5
Always validate and convert data types when processing external data.
Incorrect Use of Operators
Sometimes the operator itself is not suitable for the data type.
Example:
result = "10" - "2"
Fix:
result = int("10") - int("2")
Python does not support subtraction or division for strings.
Debugging the Error Step by Step
To debug this error effectively:
Read the full error message
Identify the operator (
+,-,*,/)Check the data types of both operands
Print or log variable values before the error line
Example:
print(type(a), type(b))
This helps you quickly identify mismatched types.
Comparison Table of Common Operand Errors and Fixes
The table below summarizes frequent operand-related errors in Python data processing and how to fix them.

Join the conversation! Your thoughts help the community grow.