title: generator vs break in list search
body: <p>I have a list of 100 000 elements and i have an element 4 at end of that list.</p>
  
  <p>In this point, what is the difference between these approaches?</p>
  
  <p>method 1:</p>
  
  <pre><code>def arr_f():
    for i in arr:
        if i==4:
            yield i
  arr=[........100k entries]
  gen_ob=arr_f()
  
  for i in gen_ob:
      #do some op
  </code></pre>
  
  <p>Method 2:</p>
  
  <pre><code>def arr_f():
    for i in arr:
        if i==4:
            break
    else:
        return True
    return False
  </code></pre>
  
  <p>In Method 2 I am waiting for number 4 to come and break the loop if I hit it. In this case does the generator givs any advantage over method 2?</p>
  
  <p>What I know on generator is it will yield a value on fly.
   In my case does my method 2 store more elements than method 1?</p>