python更新列表的值怎么继续获取其索引

我想使用值来找到指定的索引。
但是值发生改变后就无法获取该值的索引值了。(索引值不变,只是值变了,但这也导致无法继续使用该值)
如何更新列表当中的该值,按照我下面的思路,该如何编写代码。
代码以及思路如下:


```python
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
import re
l = '('  # 设置符号变量
r = ')'
hjfj1 = 'hello'
root = ttk.Window(
    title='''填词测试''',
    themename='solar',  # 设置主题
    size=(600, 600),  # 窗口的大小
    position=(300, 100),  # 窗口位置
    resizable=(False, False),  # 让窗口不可更改大小
    alpha=0.91,  # 窗口透明度
    # iconphoto=r'res\at.ico'
)

str = 'hello world,hello,world,python'
showtag_text1 = ttk.Text(root, height=4, cursor='heart')
showtag_text1.place(x=0, y=0, width=500)
showtag_text1.insert('insert', str)


def add_hello():
    try:
        get_str = showtag_text1.get('1.0', END)  # 这个字符串是用户输入的,我们获取到输入的值,这个值都是用逗号隔开的
        str_to_list = get_str.split(',')  # 先转换字符串为列表

        index_hjfj = str_to_list.index(hjfj1)  # 获取指定元素索引,该值是hello,但是加完括号后就变成了(hello),索引不变但是我无法继续使用该值
        #如何继续使用该值进行获取索引,我不知道该如何更新。
        s1=str_to_list[index_hjfj]

        s2=re.sub(rf'\b({hjfj1})\b', f'{l}\\1{r}', s1)


        str_to_list[index_hjfj]=s2

        text_over = ','.join(str_to_list)  # 删改完成列表后重新加入为字符串
        text_over.strip()  # 删除末尾多余空格

        showtag_text1.delete('1.0', END)  # 重新清理文本框内容
        showtag_text1.insert('insert', text_over)  # 最后向文本框插入内容

    except:
        pass

def rec_hello():
    '''减权重函数'''

    try:
        hjfj1_bt_text = showtag_text1.get('1.0', END)
        hjfj1_mix=l+hjfj1+r
        s = hjfj1_bt_text.index(hjfj1_mix)
        l666 = list(hjfj1_bt_text)  # 把字符串拆分为列表,列表里面全部是单个字母的字符
        l1 = l666
        del l1[s]
        del l1[s + len(hjfj1_mix)-2]
        ss = len(hjfj1_mix) + 1
        l666.insert(s + ss, '')
        l_over = ''.join(l666)  # 删改完成列表后重新加入为字符串
        l_over.strip()
        showtag_text1.delete('0.0', END)
        showtag_text1.insert('insert', l_over.strip())
    except:
        pass

ttk.Button(root, text='+括号', command=add_hello).place(x=10, y=90)
ttk.Button(root, text='-括号', command=rec_hello).place(x=10, y=140)
root.mainloop()

```

维护一个值与索引的dict:

{
  val1: index1,
  val2: index2
}

在更新值的时候,也更新这个dict。我不清楚我是不是理解了你的意思。

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^