TypeError: can only concatenate list (not "str") to list
Exception: TypeErrorCategory: runtimeRaised at: the + operator, when one side is a list and the other is a string
What this error means
You used + between a list and a string. For lists, + means 'join two lists into a new list' — both sides must be lists. A string on the right is refused outright.
Read the message in two parts: can only concatenate list (the left side is a list, so the right must be one too) not "str" to list (what you actually supplied).
Cause 1 — you meant append, not concatenate
This is the cause in most reports. The intent was 'add this one item to the list', but + is not how you add an item:
names = ["Asha", "Ravi"]
new = "Meena"
names = names + new # TypeError
Traceback (most recent call last):
File "demo.py", line 4, in <module>
names = names + new
~~~~~~^~~~~
TypeError: can only concatenate list (not "str") to list
Three correct shapes, depending on what you want:
names.append("Meena") # add ONE item in place -> ['Asha','Ravi','Meena']
names += ["Meena"] # same thing, wrapped in a list
names = names + ["Meena"] # new list, original untouched
names.extend(["Jo", "Kim"]) # add SEVERAL items in place
Cause 2 — you meant to build a string
Sometimes the list was never meant to be a list. If the goal is text, convert explicitly or use an f-string:
items = ["milk", "eggs"]
print("Shopping: " + str(items)) # Shopping: ['milk', 'eggs']
print(f"Shopping: {items}") # same, and clearer
print("Shopping: " + ", ".join(items)) # Shopping: milk, eggs <- usually what you want
Cause 3 — a function returned a list where you expected text
The same crash appears when a value's type is not what the surrounding code assumes — a function returning a list, a JSON array, or str.split():
def tags(post):
return ["python", "debug"] # a list, not a string
line = "Tags: " + tags({}) # TypeError
line = "Tags: " + ", ".join(tags({})) # Tags: python, debug
The rule, and the sibling errors
+ in Python is type-strict and each type defines it differently. There is no automatic conversion between text and collections:
[1, 2] + [3] # [1, 2, 3] list + list -> new list
[1, 2] + "3" # TypeError list + str -> this error
"1" + "2" # '12' str + str -> new string
"1" + 2 # TypeError str + int -> 'can only concatenate str (not "int") to str'
(1, 2) + (3,) # (1, 2, 3) tuple + tuple
When in doubt, print type(value) on both sides of the +. The mismatch is always visible in one line.
How to debug it
- Ask what you actually wanted: one more item in the list, or one longer string? The fix follows from the answer.
- For an item, use
append(one) orextend(several) — not+. - For text, use an f-string or
str(value);", ".join(...)if the goal is readable output. - Print
type()of both operands. If one came from a function call, check what that function returns on every path. - Remember
+never mutates —names + [x]builds a new list and throws the old one away unless you assign it.appendmutates and returnsNone.
Fix it interactively
These free problems are the same list-and-string mix-up — repair them in the browser:
- extend() vs append() easy
Related messages worth knowing
- can only concatenate str (not "int") to str — the same rule with the string on the left.
- unsupported operand type(s) for + — the third wording of the same type-strict rule.
- TypeError: the parent guide — the famous wordings decoded together.
🇮🇳 Hindi में समझें
TypeError: can only concatenate list (not "str") to list ka matlab hai aapne list aur string ko + se jodne ki koshish ki. List ke liye + ka matlab hai do lists ko jodna — dono taraf list honi chahiye. Sabse common wajah: aap ek item list me add karna chahte the, jodna nahi. Fix: names.append("Meena") (ek item) ya names.extend(["Jo", "Kim"]) (kai items) — + mat lagao. Agar sach me text banana tha to f-string use karo: f"Shopping: {items}", ya readable output ke liye ", ".join(items). Yaad rakho: append list ko badalta hai aur None return karta hai; names + [x] nayi list banata hai, purani ko chhedta nahi.