TypeError: sequence item 0: expected str instance, int found (tested fix)

TypeError: sequence item 0: expected str instance, int found comes from str.join() when an item isn't a string. We reproduced it for seven types in Python 3.13 and tested the fix for each.

1. join only accepts strings

str.join() does not convert items. Every item must already be a str. The message tells you the index of the first bad item and its type. We tried seven types:

for label, items in [("int", [1, 2]), ("float", [1.5]), ("None", ["a", None]), ("list", [["a"], ["b"]]), ("tuple", [("a", 1)]), ("dict", [{"a": 1}]), ("bytes", [b"a"])]:
    try:
        ", ".join(items)
    except TypeError as e:
        print(f"{label:6} TypeError: {e}")

Output:

int    TypeError: sequence item 0: expected str instance, int found
float  TypeError: sequence item 0: expected str instance, float found
None   TypeError: sequence item 1: expected str instance, NoneType found
list   TypeError: sequence item 0: expected str instance, list found
tuple  TypeError: sequence item 0: expected str instance, tuple found
dict   TypeError: sequence item 0: expected str instance, dict found
bytes  TypeError: sequence item 0: expected str instance, bytes found

Note the None case reports sequence item 1: the index points at the first non-string, which helps when only some items are bad.

2. The fix: convert each item

nums = [1, 2.5, None]
print(", ".join(map(str, nums)))
print(", ".join(str(x) for x in nums if x is not None))
rows = [["a", "b"], ["c"]]
print(" | ".join(", ".join(r) for r in rows))       # nested lists: join each row
pairs = [("a", 1), ("b", 2)]
print(", ".join(f"{k}={v}" for k, v in pairs))
print(b", ".join([b"a", b"b"]))                    # bytes: join with a bytes separator

Output:

1, 2.5, None
1, 2.5
a, b | c
a=1, b=2
b'a, b'

map(str, items) is the shortest fix, but it turns None into the text "None". Filter it out first if that is wrong for your output. For nested lists, join each inner list first. For tuples or dicts, format each one with an f-string. For bytes, join with a bytes separator (b", ".join(...)). If you are building CSV, use the csv module instead, which converts and quotes for you. For + between a string and a number, see can only concatenate str (not "int") to str.

Frequently asked questions

How do I fix sequence item 0: expected str instance, int found?

Convert each item: ', '.join(map(str, items)) or ', '.join(str(x) for x in items).

Why does it say sequence item 1 instead of 0?

The number is the index of the first item that isn't a string. Earlier items were fine.

How do I join a list of lists?

Join each inner list first: ' | '.join(', '.join(row) for row in rows).

Written with AI assistance. Measured on 2026-10-22 on Debian with Python 3.13.5: str.join over int, float, None, list, tuple, dict and bytes items, and the map(str), filter, nested-join, f-string and bytes-join fixes. Every block was run verbatim and its output pasted unedited. PlainHeaders is our extension; Python is free.