title: Why does my for loop only run when inside of a while loop?
body: <p>Hi for some reason this code works. I cannot figure out why:</p>
  <pre><code>some = 0
  n = 5
  while some == 0:
      for title in itertools.islice(driver.find_elements_by_css_selector(&quot;a[class='link-title']&quot;), n):
          print(title.text)
          some += 1
  
  </code></pre>
  <p>if I remove the while loop and only run the for loop, I have no output.</p>
  <p>My goal here is to collect the first five titles present in a webpage, hence the itertools. Originally, I tried doing this with the while loop, but it just provided me all the titles. This is how I came across this strange solution that seemingly works.</p>
  <p>When I try to run it with the for loop alone, without the while loop, it gives me no output. I don't get the list of title that I want.</p>
  <p>But I don't like it. I can't figure out why it works</p>