Python - How to change values in a list of lists?

后端 未结 8 2018
鱼传尺愫
鱼传尺愫 2021-02-07 20:14

I have a list of lists, each list within the list contains 5 items, how do I change the values of the items in the list? I have tried the following:

    for [ite         


        
8条回答
  •  梦如初夏
    2021-02-07 21:10

    The problem is that you are creating a copy of the list and then modifying the copy. What you want to do is modify the original list. Try this instead:

    for i in range(len(execlist)):
        if execlist[i][0] == mynumber:
             execlist[i][1] = myctype
             execlist[i][2] = myx
             execlist[i][3] = myy
             execlist[i][4] = mydelay
    

提交回复
热议问题