Error guide · AttributeError
AttributeError: object has no attribute
You used a method or attribute that this kind of value does not have.
Example
names = ["Riya", "Arjun"] names.push("Meera") print(names)
What Python says
AttributeError: 'list' object has no attribute 'push'
As printed by Python 3.12. Other versions may word it slightly differently.
Why it happens
Each type has its own methods. Lists use append, not push (that is JavaScript). The error also appears with a spelling mistake in a method name, or when a variable holds a different type than you think, such as None.
How to fix it
names = ["Riya", "Arjun"] names.append("Meera") print(names)
Output: ['Riya', 'Arjun', 'Meera']
Tips
- Check the spelling of the method, for example
.upper()not.uppercase(). - Use
print(type(x))to see what kind of value you really have. 'NoneType' object has no attributemeans the variable is None, often because a function did notreturnanything.