类型错误 'int'

TypeError 'int'

我正在尝试为一个数字列表创建一个 returns 所有可能排列的函数,例如: 列表= [1,2,3]

[[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],[3,2 ,1]]

然而我一直运行陷入同样的​​错误 类型错误:'int' 对象不可调用 在这一行

return permutations(result,variable,List,permutations)

剩下的代码是

def permutationsaux(List):
    if List==[]:
        return []
else:
    return permutations([List],0,List,countpermutations(List))

def permutations(result,variable,List,permutations):
    if len(result)==permutations:
        return result
    elif len(result[variable])==len(List):
        result.append([])
        variable=variable+1
        return permutations(result,variable,List,permutations)
    return permutations(result[variable]+reorderlist(List),variable+1,reorderlist(lista),permutations)

def countpermutations(List):
    if List==[]:
        return 1
    return len(List)*countpermutations(List[1:])

def reorderlist(List):
    temp=List[len(List)-2]
    List[len(List)-2]=LIst[len(List)-1]
    List[len(List)-1]=temp
    return List

您的函数 "permutations" 有一个名为 "permutations" 的参数。猜猜哪个在函数范围内。