Mar-13-2019, 07:15 PM
(Mar-13-2019, 07:11 PM)ichabod801 Wrote: It's not clear, because you haven't shown us how you call Optm in the first place. But if you only want the else clause to execute if none of the if clauses do, then the middle if's all need to be elif's (short for else if).
OrgH = [73.35,111.37,92.70,70.73,67.71,77.84] BtmGap = 32 MinRH = 12 Div = 7 tH = 400 sH = sum(OrgH) q = Div - len(OrgH) def Optm(S, H, GH, q): s = H + GH if S >= s: K = S - s if S < s and GH > MinRH / 12: K = Optm(S, H, GH - 1, q) if S < s and GH <= MinRH / 12: K = Optm(S + 1, H, GH, q) if S == 494: print(K) print(K/q) print(s) print(S-s) print(GH) if q < 0: print("Somethign wrong with the category!") if q == 0: return 0 else: minGap = K / q if minGap < MinRH: return Optm(S + 1, H, GH, q) if minGap >= MinRH and S <= s: return Optm(5 + 2, H, GH, q) else: return minGap L = Optm(tH, sH, BtmGap, q)sorry, I missed one line.