title: Python: skip lines of programming based on a condition in a while loop?
body: <p>The program I have is rather complicated so I've just decided to take this portion.
  Basically, this code is supposed to loop through a series of lines and stop once <code>TIME</code> has reached 4800; however, if <code>quepax</code> has reached 15 in a loop, it will evaluate <code>R</code>. If the loop is not yet broken by <code>TIME&gt;=4800</code>, subsequent loops will not get new values of <code>R</code> (since <code>quepax</code> will always be more than 15 from there) while still going through the rest of the lines. Below is an attempt to do such a program. It sort of works, but is it possible to make a simpler code without repeating content?</p>
  
  <pre><code>    while True:
              i+=1
              pax[i]=random.randint(1,5)
              TOTALPAX+=pax[i]
              TIME+=between[i]
              queue+=pax[i]
              if quepax&gt;15:
                  R=i-1
                  while True:
                      i+=1
                      pax[i]=random.randint(1,5)
                      TOTALPAX+=pax[i]
                      TIME+=between[i]
                      queue+=pax[i]
                      if TIME&gt;=4800:
                          break
              if TIME&gt;=4800:
                  break
  </code></pre>