title: Call function twice or more in a loop
body: <p>I use the code below with <code>lambda</code> to call function once in a loop, it works but now I am trying to call the function for specific times like 3 times in a loop, I looked for it and found some solutions but they call function for specific times if there is no loop, when I try it in a loop, nothing changes. Is there a efficient way to do this?</p>
  
  <p>This one works in a loop and print only once. I want something like that to do it for 3 times.</p>
  
  <pre><code>def once():
      print "Do function once"
      once.func_code = (lambda:None).func_code
  
  once()
  </code></pre>
  
  <p>This code below doesn't change anything and it keeps on printing forever if it is in a loop, if not it works.</p>
  
  <pre><code>def repeat_fun(times, f):
      for i in range(times): f()
  
  def do():
      print 'Do function for 3 times'
  
  repeat_fun(3, do)
  </code></pre>
  
  <p>Also adding counter outside the loop helps but I think there should be a better solution for it.</p>