Say I have a list called list, which is comprised of boolean values. Also say that I have some (valid) index i which is the index of list where I want to switch the value.
Currently, I have: list[i] = not list[i].
But my question is, doesn't this iterate through list twice? If so is there are way to setup a temp value through aliasing to only iterate through the list once?
I tried the following:
temp = list[i]
temp = not temp
But this has not worked for me, it has only switched the value of temp, and not the value of list[i].
doesn't this iterate through list twice?Does it? Why do you think so?