I am writing a script to manipulate an input file in different ways. The user will specify which method to use: OPTION_1, OPTION_2, or OPTION_3. There is also an option to perform all of these methods sequentially, ALL.
I am having trouble getting the script to continue executing when the ALL option is selected. Here is what I have at the moment:
calculation_type = "ALL" # ALL, OPTION_1, OPTION_2, OPTION_3
if calculation_type == "ALL":
print("Calculation type " + calculation_type + " chosen.")
elif calculation_type in {"ALL","OPTION_1"}:
if calculation_type != "ALL":
print("Calculation type " + calculation_type + " chosen.")
# Manipulate file
elif calculation_type in {"ALL","OPTION_2"}:
if calculation_type != "ALL":
print("Calculation type " + calculation_type + " chosen.")
# Manipulate file
elif calculation_type in {"ALL","OPTION_3"}:
if calculation_type != "ALL":
print("Calculation type " + calculation_type + " chosen.")
# Manipulate file
print("Calculation finished")
This works fine for OPTION_1/2/3, but when the choice is ALL the script gets stuck at the first if statement and does not continue onto the second if statement. How can I make the script execute each if statement sequentially when ALL is selected?
elifwithif.ALLis in the set anyways? Ifcalculation_type = "ALL", the first statement executes. You then have a nestedifinside eachelifthat will only execute its body if thecalculation_typeis not"ALL". So, what's the point of checking ifcalculation_typemight be"ALL"in eachelifstatement?calculation_typeto be a set as well, if it could contain, say,OPTION_1andOPTION_2but notOPTION_3.