I have a tuple that looks like the following:
(((1, 1), False), ((1, top), False), ((right, 1), False), ((right, top), False))
So the tuple has 4 tuples in it, each of them storing a coordinate(another tuple) and a bool.
(I do not use dict or list because I need this to be hashable)
Is there a smart way to change the bool to true for a given coordinate?
So what I want to express in a one liner is this:
In state set pair to True where pair = (givenX, givenY)
Is there a smart way to do this in python?
Thanks for all the answers. Here is what I did in the end:
state = dict(state) if (givenX, givenY) in state.keys(): state[(givenX, givenY)] = True state = tuple(state.items())