我想合并的名称取决于它收到什么项目
例如,我有另一个函数返回每个列表,如下所示:
项目:
["name"]
None
["name"]
None
["name"]
["king"]
None
None
["king"]
["king"]
这些将逐一返回到函数“def learn()”
def learn():
#item goes in here one by one
if item is None:
return ["{]{}".format(xx,xx) for xx in item]
else:
return["{}{}".format(i,i) for i in item]
我希望我的输出是这样的:None应该采用与第二个插入的字符串列表相同的名称
输出:
[“名称”][“名称”] [“名称”][“名称”]
[“国王”][“国王”] [“国王”][“国王”]
目前没有回答
相关问题 更多 >
编程相关推荐