Jul-16-2019, 02:04 PM
Hi All!
I am hoping to combine a series of conditions, and I need to find the cleanest possible setup. I have yet to find any that work. My current setup is as follows:
I have my conditions listed as follows:
What I am having trouble with is creating the next output - I need a simple® way to combine conditions
so that when thing_1 = A and thing_2 = B and thing_3 = C, the operation will print ("YOGURT") and still when thing_1 = B and thing_2 = A and thing_3 = C (the same outputs but from different inputs) it will still print ("YOGURT") but when thing_1 = D and thing_2 = E and thing_3 = F, the operation prints ("APPLES")instead. In simple words - when any combination of A B and C are present, I want the same output, but when D is added, I want a different output, or when any other combination is present, another specific output.
This is the setup I am currently working with:
I do not see this working out as I would need to write out every possible condition where A and B and C are present, then move on to every possible condition where B and C and D are present, and so fourth. Any ideas? I know a list or array would come of use, I just don't know in which area, if not all.
Thank you for your help!
I am hoping to combine a series of conditions, and I need to find the cleanest possible setup. I have yet to find any that work. My current setup is as follows:
I have my conditions listed as follows:
thing_1 = input('What is on thing 1? ') thing_2 = input('What is on thing 2? ') thing_3 = input('What is on thing 3? ') thing_4 = input('What is on thing 4? ') thing_5 = input('What is on thing 5? ') thing_6 = input('What is on thing 6? ')Next I have a series of outputs for those inputs that look like this:
thing_1_A = ["0", "12"] if thing_1 in thing_1_A: print("A") thing_1_B = ["1", "13"] if thing_1 in thing_1_B: print("B") thing_2_A = ["1", "13] if thing_2 in thing_2_A: print("A")ETC...
What I am having trouble with is creating the next output - I need a simple® way to combine conditions
so that when thing_1 = A and thing_2 = B and thing_3 = C, the operation will print ("YOGURT") and still when thing_1 = B and thing_2 = A and thing_3 = C (the same outputs but from different inputs) it will still print ("YOGURT") but when thing_1 = D and thing_2 = E and thing_3 = F, the operation prints ("APPLES")instead. In simple words - when any combination of A B and C are present, I want the same output, but when D is added, I want a different output, or when any other combination is present, another specific output.
This is the setup I am currently working with:
if thing_1 in thing_1_A and thing_2 in thing_2_B and thing_3 in thing_3_C and thing_4 in thing_4_C and thing_5 in thing_5_A and thing_6 in thing_6_A: print("This is a condition 1")
I do not see this working out as I would need to write out every possible condition where A and B and C are present, then move on to every possible condition where B and C and D are present, and so fourth. Any ideas? I know a list or array would come of use, I just don't know in which area, if not all.
Thank you for your help!