首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError 'int‘

TypeError 'int‘
EN

Stack Overflow用户
提问于 2015-05-19 16:53:05
回答 1查看 28关注 0票数 0

我试图建立一个函数,返回一个数字列表的所有可能排列,例如: List= 1,2,3

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

但是,我始终遇到相同的错误TypeError:'int‘对象在该行中不可调用

代码语言:javascript
复制
return permutations(result,variable,List,permutations)

其余的代码是

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-19 16:56:44

您的函数“置换”有一个名为“置换”的论点。猜猜函数中的作用域是哪一个。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30331644

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档