Python errors › AttributeError
AttributeError: 'list' object has no attribute
Updated
The Python error "'list' object has no attribute" means a method from another language, like push, or a str method on a list. Python 3.15 names the fix.
What you see
items = [1, 2, 3]
items.push(4)Traceback (most recent call last):
File "/home/me/project/main.py", line 2, in <module>
items.push(4)
^^^^^^^^^^
AttributeError: 'list' object has no attribute 'push'. Did you mean '.append'?What it means
Lists do not have a method called push. That is JavaScript's name; in Python the method is append. Python 3.15 knows the common method names from JavaScript, Java, Ruby and C# and suggests the Python one, as above.
The other frequent version of this error is a list where you expected something else, such as a string, a dict or a single object.
Why it happens
These are the names people reach for most often, with the Python equivalent:
pushoradd: useitems.append(x), oritems.extend(more)for several.addis the method of a set.length,sizeorcount()for the length: uselen(items).items.count(x)exists, but counts occurrences ofx.includesorcontains: usex in items.indexOf: useitems.index(x), which raisesValueErrorwhenxis not there.split,lower,striporreplace: these are string methods. You have a list, often from an earliersplit()orreadlines(); loop over it, or join it first.get,keysoritems: these belong to a dict. JSON that you expected to be an object may be a list of objects.
How to fix it
Use the Python method, or check what the variable holds:
items.append(4)
print(type(items), items[:3])
For string methods on a list of strings, apply them to each item:
lines = [line.strip() for line in lines]
Example: a JavaScript string method
name = "ada"
print(name.toUpperCase())Traceback (most recent call last):
File "/home/me/project/main.py", line 2, in <module>
print(name.toUpperCase())
^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'toUpperCase'. Did you mean '.upper'?| Python | Prints |
|---|---|
| 3.9–3.14 | AttributeError: 'str' object has no attribute 'toUpperCase' |
| 3.15 | AttributeError: 'str' object has no attribute 'toUpperCase'. Did you mean '.upper'? |
Run on CPython 3.9.6, 3.10.22, 3.11.17, 3.12.15, 3.13.17, 3.14.9 and 3.15.1, on October 25, 2026.
Example: a Java map method on a dict
ages = {}
ages.put("ada", 36)Traceback (most recent call last):
File "/home/me/project/main.py", line 2, in <module>
ages.put("ada", 36)
^^^^^^^^
AttributeError: 'dict' object has no attribute 'put'. Use d[k] = v.| Python | Prints |
|---|---|
| 3.9–3.14 | AttributeError: 'dict' object has no attribute 'put' |
| 3.15 | AttributeError: 'dict' object has no attribute 'put'. Use d[k] = v. |
Run on CPython 3.9.6, 3.10.22, 3.11.17, 3.12.15, 3.13.17, 3.14.9 and 3.15.1, on October 25, 2026.
How each Python version words it
| Python | Prints |
|---|---|
| 3.9–3.14 | AttributeError: 'list' object has no attribute 'push' |
| 3.15 | AttributeError: 'list' object has no attribute 'push'. Did you mean '.append'? |
Run on CPython 3.9.6, 3.10.22, 3.11.17, 3.12.15, 3.13.17, 3.14.9 and 3.15.1, on October 25, 2026.
Up to 3.14 these examples end at "has no attribute 'push'". 3.15 adds a hint: "Did you mean '.append'?", "Did you mean '.upper'?", and for the dict, "Use d[k] = v." The hints work on subclasses of the builtin types as well.
Questions
Why is there no push alias?
Python has one name for each operation on its builtin types. append adds one item to the end; insert(0, x) adds at the front.
How do I tell a list from a string when debugging?
print(type(x)) names the type, and print(repr(x)) shows the value with its brackets or quotes.
Sources
- More on lists, Python tutorial
- Mutable sequence types, Python documentation
- What's New in Python 3.15: improved error messages, Python documentation
Read on October 25, 2026.