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.]
row1 = [str1, str2, etc.]
I am trying to remove any $ or % signs that appear in the strings in a row list. I have checked that if I try and do this for one individual element, say the second row and the fourth element has a "%", so:
data[1][3] = data[1][3].replace("%","")
This will properly remove it, but when I try and use a nested for loop to do it all:
for row in data:
for x in row:
x = x.replace("%","")
x = x.replace("$","")
This doesn't remove any of the % or $ signs, I have tried just doing it without the second replace to see if it would at least remove the % signs, but even that didn't work.
Any ideas why this wouldn't work, or how I could do this?
Thanks in advance for any help!
stras a name for a variable in Python. It is also a function!for-indoesn't affect the actual list because the element is stored/copied into a variable, it's not a direct reference. Use enumerate and access list.