when the condition in last "IF STATEMENT" is satisfied for the first j, first g and first s, i want to break all 3 loops containing j, g and s and the code should try next i. If the last "IF STATEMENT" is not satisfied, the code should try next s, next g and next j respectively.
I tried using a flag variable. but it does not give me the result i want. I have made a mistake somewhere. Please help me out to solve this issue. I'm running out of time and really stressed about this matter since i have limited knowledge in python. I would be much grateful if you could sort this problem.
for i  in range(len(A.hp)):
   gg= False
   while gg==False:
     for j in range(len(run_parameters.bits_Mod)):
      req_slots[j] = math.ceil((A.T[i]["Traffic"])/(run_parameters.bits_Mod[j]*C))
      for g in Temp[i]["Available_ranges"][j]:
       for s in range(g[0], g[-1]):
          if (s+req_slots[j]-1) <= g[-1]:
             if (Temp[i]['cost'][j] <= (run_parameters.PSD)/(run_parameters.OSNR_threshold[j])):
               served_count +=1
               A.T[i]["First_index"]= s
               A.T[i]["Last_index"]= s+req_slots[j]-1
               A.T[i]["Status"]= 1
               A.T[i]["Selected_MOD"] = j
               gg=True
