【发布时间】:2021-07-20 10:43:27
【问题描述】:
我想从包含关键字的列表中删除元素。
例如-
list1= [ 'one', 'one-test', 'two', 'two-test', 'three', 'three-test']
我想删除此列表中包含“-test”的所有元素。
所以最终的输出应该是-->
list1= ["one", "two", "three"] #because if it contained '-test' we just deleted the element as a whole
【问题讨论】: