Python 2.7:更新列表中的元素

Python 2.7:更新列表中的元素,python,list,Python,List,我想更新列表中的一个元素 这是我喜欢的清单: list= ["toto", "stack" , "element_to_update", "overflow"] 当发现元素[0]和元素[1]为时,我想更新此列表,以更新我的列表(并与现有的元素[2]连接) 最后我想要的列表: list=["toto", "stack", "element_to_update_is_updated", "overflow"] 最好的方法是什么 提前感谢您的帮助。为什么不: l = ["toto", "stack

我想更新列表中的一个元素

这是我喜欢的清单:

list= ["toto", "stack" , "element_to_update", "overflow"]
当发现
元素[0]
元素[1]
时,我想更新此列表,以更新我的列表(并与现有的
元素[2]
连接)

最后我想要的列表:

list=["toto", "stack", "element_to_update_is_updated", "overflow"]
最好的方法是什么

提前感谢您的帮助。

为什么不:

l = ["toto", "stack", "element_to_update", "overflow"]
if l[:2] == ['toto','stack']:
    l[2] += '_is_updated'
现在:

print(l)
是:

为什么不:

l = ["toto", "stack", "element_to_update", "overflow"]
if l[:2] == ['toto','stack']:
    l[2] += '_is_updated'
现在:

print(l)
是:


你尝试了什么?你有什么困难?你应该多解释一点你想要什么,你尝试了什么?你有什么困难?你应该多解释一点你想要什么