Id like to write a script in python that can return a list of boolean value, that changes the value based on weather or not it hits a keywordeg:if I have a list [hello, what, switch, am, i, doing, switch, here]I need to get it to return : [True, True, False, False, False, False, True, True]essentially it'll change the boolean value (always beginning as true) for itself and the following elements until it hits the keyword (switch in this case).
so far I've gotten it to only change the switch keyword itself to false.(im new to stack overflow and don't know how to add code snippets yet as ive seen other people do so bear with me on this one lol)my code looks like this:(I know where im going wrong and why its only changing one element, this is just where I got stuck on the problem)
def flick_switch(lst): x = [] for i in lst: if i == "switch": x.append(False) else: x.append(True)