title: python combine 'while loop' with 'for loop' to iterate through some data
body: <p>I am trying to combine a <code>while</code> loop with a <code>for</code> loop to iterate through some list but I am getting infinite loops. My code:</p>
  <pre><code>l=[0,2,3,4]
  lo=0
  for i in range(len(l)):
       while (True):
            lo+=1
       if lo+l[i]&gt;40:
           break
       print(lo)
  </code></pre>
  <p>This code results in an endless loop. I want an output when the condition <code>lo+ l[i]</code> is greater than 40; it should stop looping and print the final <code>lo</code> output as result. I tried every method of indentation of the print line, but could not get what I wanted. Thanks in advance.</p>