简体   繁体   English

TypeError:“NoneType”类型的参数对于作为参数传递给 function 的列表不可迭代

[英]TypeError: argument of type 'NoneType' is not iterable for list passed in as parameter to a function

Given an array nums of distinct integers, return all the possible permutations.给定一个由不同整数组成的数组,返回所有可能的排列。 You can return the answer in any order.您可以按任何顺序返回答案。

I keep getting the error, and I don't understand why.我不断收到错误,我不明白为什么。

TypeError: argument of type 'NoneType' is not iterable
    if (nums[i] not in current):

This is my code:这是我的代码:

def permute(self, nums: List[int]) -> List[List[int]]:
        output = []
        self.backtracking(nums, output, [],0, len(nums))
        return output 
        
    
    def backtracking(self, nums, outputList, current, length, maxLength):
        if (length == maxLength):
            outputList.append(current)
        
        for i in nums:
            if (nums[i] not in current):
                self.backtracking(nums, outputList, current.append(nums[i]), length+1, maxLength)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:“NoneType”类型的参数在列表理解中不可迭代 - TypeError: Argument of type 'NoneType' is not iterable in List comprehension TypeError:“NoneType”类型的参数不可迭代 - TypeError: argument of type 'NoneType' is not iterable “TypeError:'NoneType' 类型的参数不可迭代”? - “TypeError: argument of type 'NoneType' is not iterable”? TypeError:“ NoneType”类型的参数不可迭代python - TypeError: argument of type 'NoneType' is not iterable python Python聊天机器人“ TypeError:'NoneType'类型的参数不可迭代” - Python chatbot “TypeError: argument of type 'NoneType' is not iterable” TypeError:“NoneType”类型的参数不可迭代需要修复 - TypeError: argument of type 'NoneType' is not iterable need a fix Python - TypeError:“NoneType”类型的参数不可迭代 - Python - TypeError: argument of type 'NoneType' is not iterable TypeError:类型为“NoneType”的参数不是可迭代错误 - TypeError: argument of type 'NoneType' is not iterable error 国际象棋程序中的“ TypeError:'NoneType'类型的参数不可迭代” - “TypeError: argument of type 'NoneType' is not iterable” in chess program TypeError:if语句后,不可迭代“ NoneType”类型的参数 - TypeError: argument of type 'NoneType' is not iterable after an if statement
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM