所以我有以下代码:
thing = [ ['Promotion not applied', 'Buy1, get 1 for FOR $4.50', '(', 'details', ')'], [], ['Promotions Applied:', 'BUY 1, GET 1 FOR $4.50', '(', 'details', ')'] ]
因此,当它遍历一个列表时,我想为promo_applied和promo_not apply创建两个新列表:
因此返回将是:
promo_applied=["promotions applied", 'Buy1, get 1 for FOR $4.50']
promo_not_applied = ["promotion not applied", 'Buy1, get 1 for FOR $4.50']
thing = [ ['Promotion not applied', 'Buy1, get 1 for FOR $4.50', '(', 'details', ')'], [], ['Promotions Applied:', 'BUY 1, GET 1 FOR $4.50', '(', 'details', ')'] ]
promo_applied, _, promo_not_applied = map(lambda s:s[:2], thing)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句