typeerror 'builtin_function_or_method' object has no attribute '__getitem__'

前端 未结 2 1251
野趣味
野趣味 2021-01-04 00:32

Here\'s the code:

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]         


        
相关标签:
2条回答
  • 2021-01-04 00:41

    You need parenthesis instead of []:

    The_End.insert(x + 1, y)
    
    0 讨论(0)
  • 2021-01-04 00:47

    You need to change the brackets in The_End.insert[x + 1, y] to parenthesis.

    The_End.insert(x + 1, y)
    

    It's good practice in Python to use lowercase variable names. Uppercase is generaly used for classes.

    0 讨论(0)
提交回复
热议问题