python list append gives a error: AttributeError: 'function' object has no attribute 'append'
14,556
It seems you have a function in your code that is shadowing Python's built-in function named list
.
Author by
peztherez
Updated on June 12, 2022Comments
-
peztherez almost 2 years
I have
list = []
and I am adding an element to it usingself.list.append('test')
and I get this error -AttributeError: 'function' object has no attribute 'append'
The other list that I have defined
append
just fine, any ideas? -
SethMMorton almost 11 yearsI'd like to point out that everyone using python has a function called
list
in their code... it's the python builtinlist
. This is a perfect example of why it's bad practice to give variables names that shadow builtin functions.