簡體   English   中英

TypeError:“NoneType”類型的參數對於作為參數傳遞給 function 的列表不可迭代

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

給定一個由不同整數組成的數組,返回所有可能的排列。 您可以按任何順序返回答案。

我不斷收到錯誤,我不明白為什么。

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

這是我的代碼:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM