无法为两个耦合序列的给定递归关系解压不可迭代的 int 对象?

cannot unpack non-iterable int object for given recurrence relationship for two coupled sequences?

我已经为两个耦合序列创建了递归关系代码,但出于某种原因,我收到了一个错误

代码:

import math

for x,y in range(1,3):
    def Function_X_Y(x,y):
        x_val = (-5*x*(n-2)) + (2*y*(n-1))
        y_val = (3*y*(n-2)) - (4*x*(n-1)) + (4*y*(n-1)) 
        return(x_val, y_val)

def coupled_sequence(n):
    return Function_X_Y(x,y)

print(coupled_sequence(0))
print(coupled_sequence(1))
print(coupled_sequence(5))

#Expected output: print(coupled_sequence(0))
#>>> (1, 1)

#print(coupled_sequence(1))
#>>> (2, 2)

#print(coupled_sequence(5))
#>>> (246, 322)

错误

----> 5 for x,y in range(1,3):
      6     def Function_X_Y(x,y):
      7         x_val = (-5*x*(n-2)) + (2*y*(n-1))

TypeError: cannot unpack non-iterable int object 

我尝试了不同的方法在 for 循环的帮助下迭代给定的函数,但无法获得预期的输出

Range as it is being used will only return one integer each iteration, so you cannot get multiple values that way. Depending on your use case you could just create another loop inside the one you have, see this question.