. Advertisement .
..3..
. Advertisement .
..4..
I am new to python and searching the “builtin_function_or_method object has no attribute __getitem__” to understand it better. It seems it doesn’t work as expected when I used some suggestions before. Here is the command line I use:
The_Start = [1,1]
The_End = [1, 1]
for z in range(20):
for x in range(len(The_Start) - 1):
y = The_Start[x] + The_Start[x + 1]
The_End.insert[x + 1, y]
print The_End
The_Start = The_End
The_End = [1, 1]
The error I’m getting is below:
typeerror 'builtin_function_or_method' object has no attribute '__getitem__'
Please give me the solution to this issue.
The cause: The issue is that index must be called with
()
and not[]
because it is a method.Solution: It is easy to fix the typeerror ‘builtin_function_or_method’ object has no attribute ‘__getitem__’.
Use parenthesis:
Instead of the brackets:
Instead of
[]
, you need parenthesis