I'm trying to edit values in a list so I can make this list similar to another list I have elsewhere in my program.
I get a list of values from a document, and want to turn "Off" into "No", and "On" into "Yes", "" into "Null", etc.
However, the following code isn't replacing those values for some reason:
counter = 0
while counter < len(value_list)-1:
if str(value_list[counter]) in ("", " ", "N/A"):
value_list[counter] = "Null"
elif str(value_list[counter]) == "Off":
value_list[counter] = "No"
elif str(value_list[counter]) == "On":
value_list[counter] = "Yes"
counter += 1
print counter, value_list[counter]
My output is (I just took snips, since its several hundred lines):
0 ""
1 ""
2 ""
...
7 "Off"
8 "Off"
9 "Off"
10 "Off"
...
556 ""
557 ""
I looked at this post, but using enumerate just gave me the same issue as I have now. Preferably, I want to stick with a counter variable and if/elif/else statements, since I'm one of the few coders in my office, and want others to understand this easily!