的问题是这样的:Python的:把一系列的嵌套列表中的内容到一个列表
我有一系列的lists
,总是包含两个items
。这些items
中的每一个都可以是string
或其他列表。目标是找出如何使lists
中的所有这些items
出现在单个resultant_list
中,并返回resultant_list
。
到目前为止我的代码看起来像(其中巢被剥离名单):
def strip(nest):
result_list=[]
for item in nest:
if type(item) is str:
result_list.append(item)
else:
return result_list + strip(item)
我要去哪里错了吗?
告诉我们*您的代码如何不起作用。 – timgeb
我现在看到,return语句总是处于函数 – Jam