如何添加两个列表,从而使结果列表保持其他列表完好:在python中,以这种方式添加两个列表:['a','b'] + ['c'] = [['a','b'],['c']。我该怎么做呢?
['5','6','7'] + ['1'] + ['9','7'] = [['5','6','7'], ['1'], ['9','7']]
是否有可能做到这一点在Python?
当前代码:
def appendy(list_o_list):
temp_l = []
for l in list_o_list:
temp_l.append(list(l))
new_list=[]
new_list = [a + b for a, b in itertools.combinations(temp_l, 2)]
print("app",new_list)
return (new_list)
appendy([('g3', 'g1'), ('g3', 'g2')])
这不是添加列表,而是将这些列表放入附加列表中。 – jonrsharpe
你是不是要追加名单? –
你是对的。我也希望把两个列表中的附加列表 –