Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 需要帮助处理这里的检查器吗_Python 3.x - Fatal编程技术网

Python 3.x 需要帮助处理这里的检查器吗

Python 3.x 需要帮助处理这里的检查器吗,python-3.x,Python 3.x,好的,我有一个我需要创建的函数,我认为代码检查器有缺陷,我试着管理它,但我的代码似乎仍然失败 def reversecomp(L): """ assumes L is a list of lists whose elements are ints Mutates L such that it reverses its elements and also reverses the order of the int elements in every element of L.

好的,我有一个我需要创建的函数,我认为代码检查器有缺陷,我试着管理它,但我的代码似乎仍然失败

def reversecomp(L):
    """ assumes L is a list of lists whose elements are ints
   Mutates L such that it reverses its elements and also
   reverses the order of the int elements in every element of L.
   It does not return anything.
   """
    if L == []:
        return L
    elif type(L) == int:
        return L
    else:
        return reversecomp(L[1:]) + [reversecomp(L[0])]

def run_code(L):
    return reversecomp(L)
    print(L)
问题说明您需要修改L。执行此操作时,您的代码必须正常工作: L=[[0,1,2],[1,2,3],[3,2,1],[10,-10100]] 反向压缩(L) 印刷品(L)

测试:运行_代码([[0,1,2],[1,2,3])

您的输出:

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

正确输出:

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

规范中说“它不返回任何内容”;你的程序可以

L是整数列表的列表

好的,那么为什么要检查
type(L)==int
type(L)==list
根据规范始终为真时

变异L

你根本没有变异
L
;您将返回一个新列表。变异
L
意味着做类似于
L[…]=xxx
的事情

它不返回任何内容。


reversecomp

中,您根本不应该使用
return
关键字。正确的输出应该是它已经作为输出提供的内容,然后是一行,它不返回任何内容。奇怪的