Python AttributeError: 'list' object has no attribute
A plain-words explanation of this Python message: what it means, the usual causes, and the steps that fix it.
The messageAttributeError: 'list' object has no attribute 'push'
Make the error yourself
Run with Python 3.14.10. This is the smallest example we could find that shows it.
Python program (main.py)
items = []
items.push("pen")
print(items)Output (the real message)
Traceback (most recent call last):
File "main.py", line 2, in <module>
items.push("pen")
^^^^^^^^^^
AttributeError: 'list' object has no attribute 'push'Why it happens
An attribute is something that belongs to an object, such as a method like append. The message names the type of the object ('list') and the attribute that was not found ('push'). Reasons: a method name from another language (JavaScript has push, Python has append), a typo, a variable that holds a different type than you think (a None where you expected a list, or a string where you expected an object), or a file in your folder with the same name as a module that hides the real one.
How to fix it
- Read the type in quotes and the attribute. Does that type really have that method? Check with
dir(items)or the Python documentation. - Use the Python name:
append,extend,insertfor lists;addfor sets;updatefor dictionaries. - If the type is
NoneType, a function that should have returned something returned nothing. Fix the function. - Do not name your own file
random.py,json.pyoremail.py: it hides the standard module.
The corrected version
Python program (main.py)
items = []
items.append("pen")
print(items)Output (the corrected version)
['pen']How to avoid it
Use an editor with auto-complete: after you type items. it shows the methods that really exist.
Questions
How can I see which methods an object has?
Run print(dir(items)) or help(list) in Python.
This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.