I have the following OrderedDict
activities = OrderedDict([('eating',(1,False)),('drinking',(2,True)),('breathing',(3,True)),('talking',(4,False)),('walking',(5,False))])
I want to be able to able to run a function to reverse the True/False part of a particular entry.
so far I have the following:
def updateactivity(activity):
activities = OrderedDict([(k, (1,False)) if k == activity else (k, v) for k, v in activities.items()])
Which does well to switch the value to False. Is there a more elegant way to simply reverse the True/False in either direction?
Unpack each item's value into two variables/names then reconstruct with
not
.or