Replacing string element in for loop Python

后端 未结 3 710
轻奢々
轻奢々 2021-01-27 21:44

I am reading data in from a text file so each row is a list of strings, and all those lists are in a data list. So my lists look like:

data = [row1, row2, etc.]
         


        
3条回答
  •  花落未央
    2021-01-27 22:14

    You are assigning a new value to the name x but that does not change the contents of row or data. After changing x, you need to assign row[j] = x or data[i][j] = x for the appropriate column index j (and row index i). See also python 3: lists dont change their values

提交回复
热议问题