I'm trying to compare a short temporary list of values to a master list, to obtain the index number (of short list items) and set two variable values based on the index values being <= 10 or >10.
So when I have an index <=10 set out1 = 1, indexes >10 set out2 value to 1.
If no <=10 index values found, out1 = 0, no index values for >10, out2 = 0.
Here's my code that outputs: out1: 1, out2: 1, but expected out1: 1, out2: 0 based on the example list values.
(if the onList[] is empty during use, the zoneRefresh() function won't be called.)
Any assistance appreciated.
So when I have an index <=10 set out1 = 1, indexes >10 set out2 value to 1.
If no <=10 index values found, out1 = 0, no index values for >10, out2 = 0.
Here's my code that outputs: out1: 1, out2: 1, but expected out1: 1, out2: 0 based on the example list values.
(if the onList[] is empty during use, the zoneRefresh() function won't be called.)
aList = ["Bin 1", "Bin 2", "Bin 3", "Bin 4", "Bin 5","Bin 6", "Bin 7", "Bin 8", "Bin 9", "Bin 10", "Bin 11", "Bin 12", "Bin 13", "Bin 14", "Bin 15"] onList = ["Bin 3", "Bin 4"] #For test, usually empty def zoneRefresh(): out1 = 0 out2 = 0 for i in range(len(aList)): if aList[i] in onList: if(i) <= 10: out1 = 1 print("out1: " + str(out1)) else: # (i) > 10 out2 = 1 print("out2: " + str(out2))I can't see why the out2 varible is assigned a "1" when there is no value with an index greater-than 10 in the onList[].
Any assistance appreciated.