I have a list like this:
list_1 = [True, False, True, False, True, True, True, False, False, False, True, True, False]
In this list, there are sequences that start with a False and end with a True. I need help to implement replacing values of this list in this way:
- Replace
Falsevalues of these sequences with a-2^kseries. TheTruevalue after the lastFalseof each sequence is+2^k, withkas the position of the value in a sequence. - Other
Truevalues that don't belong to any of those sequences will retain value1.
The output looks like this:
list_2 = [1, -1, 2, -1, 2, 1, 1, -1, -2, -4, 8, 1, -1]