我列出的两份名单 - 即合并两个外部列表基于迭代内部列表值
[['1', 'expired', 'test', '0'], ['31', 'active', 'test', '1']]
以及
[['1', 'Andrew', 'Alexander'], ['31', 'John', 'Smith']]
让我们称之为list1
和list2
我想合并list1
和list2
,但只有当(注意,这是伪代码,试图找出如何在Python中编程)
x[0] in list1 == x[0] in list2
我不确定如何写出来。
通过合并我的意思是(伪代码)
list[x] = list1[x] + list2[x] while x[0] in list1 == x[0] in list2
输出期望:
[['1', 'expired', 'test', '0', '1', 'Andrew', 'Alexander'], ['31', 'active', 'test', '1', '31', 'John', 'Smith']]
的唯一关键点是,并不是所有的x的[0]的要匹配完美。
你说的'合并'是什么意思?什么是期望的输出? – infrared
请给出你想要的例子的输出 - 它仍然不是很清楚。 – agf
仍试图找出哪些是适合我的正确答案。我很多未被选中的答案都是这样的。我也一直试图给过去的问题提供检查标记。我正在努力成为社区的一员! –