在Python中,我有一个这样的列表:
list = ["item.1", "sdfhkjdsffs/THIS-STRING", "fsdhfjsdhfsdf/THIS-STRING",
item4/THIS-STRING, item5]
如何为不包含"some string"
的列表中的每个项目添加"THIS-STRING"
?
答案 0 :(得分:0)
result = [x if x.find("SOME-STRING")>=0 else x+"some string" for x in list]