samedi 19 décembre 2020

Python Permutations - Obtaining full set of outcomes with conditions

I have the following list of variables that take on a Boolean value:

''' outcome_value=['A','B','C'] ''' ''' outcome_type=[True,False] '''

I want to obtain the full list for possible outcomes for the three variables. The conditions I want are when A=True then B,C = False; when B=True the others equal False and so on. in other words:

''' outcomes_all = [(True, False, False), (False, True, False), (False, False, True)] '''

What code could I use to obtain the above? Please note this is a simplification of what I am looking to do I am looking to get code I could use to extend to a more complex list of outcomes.

Only thing i can think of so far is as follows

''' import random for o in outcome_value: p=random.choice(outcome_type) print(p) '''

which of course only produces one set of True False values and can produce more than one True value which I don't want. I have been trying to build out if statements as well but keep running down blind alleys with it.

Does anyone have any ideas on how to do this? Haven't seen any threads with a similar question yet.

Thanks




Aucun commentaire:

Enregistrer un commentaire