for range - 循环语法无效

for range - invalid syntax of loop

def amp1(array):
    for i in range (0,len(array),400)
    amp1 [array]= abs(max(array[i:i+400]))
    return amp1

print(amp1(node1[3]))

我收到这样的回复:

File "<ipython-input-53-972793b81fd0>", line 7
    for i in range (0,len(array),400)
                                     ^
SyntaxError: invalid syntax

您在第 7 行末尾缺少一个“:”。 让我们试试:

def amp1(array): 
    for i in range (0,len(array),400): 
        amp1 [array]= abs(max(array[i:i+400])) 
    return amp1

print(amp1(node1[3]))

您在 for 循环中错过了一个 :,for i in range (0,len(array),400):