【发布时间】:2021-01-01 11:41:15
【问题描述】:
这是我的清单
lis = [['For the first', '$7.56'], ['For the next', '$16.69'],
['For the first', '$18.34'], ['For the next', '$43.47']]
这里总会有2个"for the first"和N次"for the next"
例如;-
lis = [['For the first', '$7.56'], ['For the next', '$16.69'],['for the next','$3.4'],['for the next','$2'],['For the first', '$18.34'], ['For the next', '$43.47'],[for the next,'$34']
我想将列表分成 2 个。
1:从第一个“为第一个”到第二个“为第一个”(不包括)
2:从第二个“第一个”(包括)到最后一个元素
delivery=[]
supply=[]
for j in range(1,len(lis)):
if(lis[j][0].lower()=='for the first'):
break
else:
delivery.append(lis[j][1])
print(delivery)
【问题讨论】:
-
请更新您的问题,说明问题所在。
-
显示预期输出...
标签: python python-3.x list loops for-loop