In some part of my Python program I have a val variable that can be 1 or 0. If it\'s 1 I must change to 0, if it\'s 0 I must change to 1.
How do you do it in a Pytho
Just another possibility:
i = (1,0)[i]
This works well as long as i is positive, as dbr pointed out in the comments it doesn't work fail for i < 0.
Are you sure you don't want to use False and True? It sounds almost like it.
False
True