AttributeError: 'list' object has no attribute 'split' (tested fix)
AttributeError: 'list' object has no attribute 'split' means you called a string method on a list. We reproduced it with split, strip, lower and replace on Python 3.13 and show the two fixes.
1. String methods called on a list
split, strip, lower and replace are str methods. Calling them on a list, such as the result of readlines() or an earlier split(), raises this error. The reverse mistake, append on a string, is the mirror image:
lines = open(__file__).readlines() # a list of strings
for call in ["lines.split(',')", "lines.strip()", "lines.lower()", "lines.replace('a', 'b')", "'x'.append('y')"]:
try:
eval(call); print(f"{call:24} OK")
except AttributeError as e:
print(f"{call:24} AttributeError: {e}")
Output:
lines.split(',') AttributeError: 'list' object has no attribute 'split'
lines.strip() AttributeError: 'list' object has no attribute 'strip'
lines.lower() AttributeError: 'list' object has no attribute 'lower'
lines.replace('a', 'b') AttributeError: 'list' object has no attribute 'replace'
'x'.append('y') AttributeError: 'str' object has no attribute 'append'
2. The fix: call it on each item, or join first
rows = ["ann,31", "bob,42"]
print([line.split(",") for line in rows]) # call it on each item
print(",".join(["a", "b", "c"]).split(",")) # or join first, if you meant one string
words = "Hello World".split()
print([w.lower() for w in words])
Output:
[['ann', '31'], ['bob', '42']]
['a', 'b', 'c']
['hello', 'world']
If you wanted to process each line, loop or use a comprehension and call the method on each string. If you actually wanted one string, ",".join(lst) it first. To find where the list came from, print(type(x), x) just before the failing line. Common sources are readlines(), split() called twice, and re.findall(). For the same error on None, see our NoneType has no attribute guide.
Frequently asked questions
How do I fix 'list' object has no attribute 'split'?
Call split on each string: [line.split(',') for line in lines]. If you meant a single string, join the list first.
Why is my variable a list instead of a string?
Common sources are readlines(), an earlier split() and re.findall(), which all return lists. Print type(x) before the failing line to check.
Written with AI assistance. Measured on 2026-10-22 on Debian with Python 3.13.5: split, strip, lower and replace called on a list from readlines(), append on a str, and the per-item and join fixes. Every block was run verbatim and its output pasted unedited. PlainHeaders is our extension; Python is free.